|
Software
Files
Directory Shell Different types of shell
Networking Reference
|
The ShellWhenever you login to a Unix system you are placed in a program called the shell. You can see its prompt at the bottom left of your screen.(i.e Paris).To get your work done, you enter commands at this prompt. The shell acts as a command interpreter; it takes each command and passes it to the operating system kernel to be acted upon. It then displays the results of this operation on your screen. Following are few of the features of the shell :Create an enviornment Working environment is defined whenever you login or start another shell. This environment is set using the values that the shell finds in initialisation files which it always reads as it starts up. You can change your working environment by editing these files and setting new values for variables. Each shell handles its initialisation files in a different way. Frequently used Environment Variables
Finding out which shell you are usingInformation about which shell you are using is held in the SHELL environment variable.The command echo $SHELL displays the value of this variable. You can identify which shell you are presently using from the last part of the pathname.
To view all the environment variables,use the command printenv
Changing your environment :Bourne shell At login the Bourne shell reads the initialisation files /etc/profile and $HOME/.profile. You cannot change the content of /etc/profile, but you have permission to edit the contents of .profile, which is in your home directory and is owned by you. Useful tip : Make a copy of your shell start up file before editing it to change environment or shell variables. You can always return to using this copy if you find that the modified file is not working and you are unable to fix the problem. For example: cd cp .profile old_profile pico .profile The first command changes you to your home directory, where a copy of the file .profile is made in old_profile. You can then edit the .profile. To revert to using the original .profile you simply copy it back. For example: cp old_profile .profile Displaying current variables You can use the echo command to display the value of an environment variable. For example: echo $PATH This displays the value of the environment variable PATH. The name of an environment variable is given in UPPER CASE. The $ sign is a shell metacharacter that uses the value of the variable instead of its name. The method for displaying the value of every variable varies according to which shell you are using. For the Bourne shell use the command set to display the value of environment variables. For the C and TC shell use the command printenv or env to display the value of environment variables and the command set to display the value of local shell variables. If the list of variables is so long that it scrolls off the screen and you want to display the information one screenful at a time, pipe the output through a pager. For example: set | more Setting environment and shell variablescshTo set an environment variable in csh, use the setenv command. The command has the syntax: setenv VARIABLE value. To set the EDITOR variable to the value emacs in csh, use the command: setenv EDITOR emacs. sh, or kshTo set an environment variable in sh or ksh, use the syntax VAR=value;export VAR, where VAR is the name of the environment variable and value is the value you wish to assign. Do not put spaces on either side of the equals sign. The export command instructs the shell to propagate the value of the variable to all programs that are run by the shell. If an environment variable is reset, but not exported, the change will only apply to the shell itself. To set the EDITOR variable to the value emacs in ksh or sh, use the command: EDITOR=emacs;export EDITOR It is also possible to unset environment variables, with the unset command. Unsetting an environment variable removes the definition of the variable.
|