Page 165 - DCAP602_NETWORK_OPERATING_SYSTEMS_I
P. 165
Unit 9: File System Commands
in Linux. That means whenever you type a command, Linux would search for that program in notes
all the directories that are in its PATH. Since there is a period in the PATH, Linux would also
look in the current directory for program by the name (the directory from where you execute
a command). Thus whenever you execute a program which is present in the current directory
(maybe some scripts you have written on your own) you don’t have to type a ‘./programname’ .
You can only type ‘programname ‘ since the current directory is already in your PATH.
Remember that the PATH variable is a very important variable. In case you want to add some
particular directory to your PATH variable and in case you try typing the following:
PATH =/newdirectory
This would replace the current PATH value with the new value only. What you would want is to
append the new directory to the existing PATH value. For that to happen you should type:
PATH=$PATH:/newdirectory
This would add the new directory to the existing PATH value. Always a $VARIABLE is
substituted with the current value of the variable.
PS1=boss
PS1 is the shell prompt. It defines what you want your shell prompt to look like. By default it
looks like a ‘ $ ‘ in bash shell. The above case would replace the default ‘ $ ‘ with a new ‘boss’.
Hence an ls command would look something like:
boss> ls
All your commands would now be typed at a ‘boss’ prompt instead of a ‘ $ ‘ prompt.
SHELL=/bin/bash
This tells where the program that represents your shell is to be found. In case you typed /bin/
ksh in the above, then your bash shell would be replaced with the ksh shell (korn shell). So in case
you are not happy with the bash shell, you could replace the bash with some other shell.
LOGNAME=ramesh
The LOGNAME is automatically set for you as the same as your login name. This variable is used
in case you want to use your own login name in any script. This is the simplest way of getting
your login name from within a script. Thus in case you use $LOGNAME in any script the script
would work for all users since the LOGNAME always holds the name of the current user.
A good use is in case you have been given a temporary directory to work with and to make
temporary files then you would want to delete the files that you created. You could use a
command with the $LOGNAME in it to locate files that were created by you and then you could
pass the result of this command to a rm command. This would be a neat way to delete all the files
at one go, rather than find them one at a time.
There are more environment variables then the ones that are mentioned here. But most users
would find the ones given here to be useful.
Note There are more environment variables then the ones that are mentioned here.
But most users would find the ones given here to be useful.
LoveLy professionaL university 159