The Shell is a user interface or a default user environment where a user enter commands that are executed by OS. It is used as a command line interpreter.The shell is the interpreter that allows you to interact with the Linux using various commands. Linux shell can process commands in various sequences depending on how you manage the input and output of each command. We can change the default shell for individual users in the /etc/passwd file.
To see the available shells for CentOS/RHEL 7 ……..
[root@TEST/]# cat /etc/shells
1. /bin/sh : Bourne shell developed by Stephen Bourne. At present work as a symlink or hardlink to represent the default shell.
2. /bin/bash : Bourne Again Shell default for users of Linux systems, written by Brian Fox for the GNU Project as a replacement for the Bourne Shell.
3. /bin/tcsh : tcsh is an enhanced but completely compatible version of the Berkeley UNIX C shell,csh.
4. /sbin/nologin : Allow a user login without shell.
6. /bin/ksh : Korn shell developed by David Korn of Bell labs. Includes all the features of C
shell, tcsh & with the script language features similar to that of the Bourne shell.
7. /bin/rksh The rksh command invokes a restricted version of the Korn shell. It allows administrators to provide a controlled shell environment to the users.There is also a restricted version of rksh available for the enhanced Korn shell , called rksh93.
With a restricted shell a user cannot:
- Change the current working directory.
- Set the value of the SHELL, ENV, or PATH variable.
- Specify the pathname of a command that contains a / (slash).
- Redirect output of a command with > (right caret), >| (right caret, pipe symbol), <> (left caret, right caret), or >> (two right carets).
Shell Environment: When you login in a shell an environment is created to ensure that all is that is happening is happening the right way. This environment consists of variables that define the user environment. To display the current environment use command “env”.When a user logs in, an environment is created for that user automatically.This happens based on four different files where some script code can be specified and where variables can be defined for use by one specific user:
■ /etc/profile: Variables defined in this file adapted by all users upon login.
■ /etc/bashrc: This file is adapted when subshells are started.
■ ~/.bash_profile: Currently logs in or user-specific login shell variables can be defined.
■ ~/.bashrc: Currently logs in or user-specific file, subshell variables can be defined.
A login shell is the first shell that is opened for a user after the user has logged in. From the login shell, a user may run scripts, which will start a subshell of that login shell.
Play with Shell Environment:
/etc/motd: This file display a message after successful login in to a shell. If you are logged in GUI,then you do not see its contents after login. Edit the /etc/motd file as below
Press "i" after that write your message.For save and exit type ":wq"
Press "i" after that write your message.For save and exit type ":wq"
Now press Ctrl+Alt+F2 and login with user-name and password. After successful login it will display your message.
/etc/issue: The contents of this file display before the login.
Press "i" after that write your message.For save and exit type ":wq"
No comments:
Post a Comment