The libname definition exists to a SAS session as long as "sas ... " is running. As soon as the SAS session goes away, the libname definition goes away for that session.
BUT,
the libname can be automated through a couple different mechanisms that I know of so that it is not necessary to code it into every SAS program:
1) autoexec.sas can be used to issue commonly used libname definitions.
2) A metatdata server. It is possible to have a sas session connect to a metadata server and for the server to then automatically provide access to libraries. Even batch SAS can do this, not just with EG and other SAS products.
We, where I am, have PC SAS on our local workstations and access to multiple SAS servers. We have an autoexec.sas file on our local PC's that points to another "autoexec.sas" file on our common server, which then %include's a file we call "LibaryDefinitions.sas". The autoexec's are specific to each user, but the LibraryDefinitions.sas file is common to all of our group's users and programs. It defines commonly used filenames libnames and options. This provides a single point of reference and maintenance, and insures commonality and portability. It also is a productivity aid since we don't have to code all that stuff every time into our programs. And, due to many issues (local and with SAS) we use it for our Logical EG servers as well, instead of the MetaData Libraries; although, I suppose with better administration, we could make more use of the MetaData Server.