The shell provides a common interface to a number of tools in the system. For example, if the shell needs to perform an action that requires a system command, it will search for the command and then execute it on behalf of the user.

What are the different types of shells?

A non-login shell or a login shell is used in this example, which employs the Bash shell. Shells execute pre-configured scripts to establish their environments. The shell plays an important role in the Linux operating system architecture. It receives input from users and sends instructions to the kernel, and it receives output from the kernel and returns it to the user. A shell executes a predetermined set of scripts to configure its environment. The Bash shell, for example, is used.

What is a Login Shell in Unix/Linux System?

When a user successfully logs in to a Linux system via terminal, SSH, or switches to a user with the “su -” command, a Login shell is created. When a login shell starts, it executes a set of pre-configured scripts to set up the environment. You may run this command on the terminal to discover which shell you are using. If the result is “-bash” or “-su”, you are on the login shell. Be certain that it has a hyphen (-) as a prefix. The following scripts are executed by the Login Shell:

What is a Non-Login Shell in Unix/Linux System?

A non-login shell is started by a login shell. For example, a shell that you start from another shell or from a program is a non-login shell. A shell that is not used to log in to the system executes the following script to set the shell environment.

Checking whether a shell is a login or non-login shell

To find whether the current shell is a login shell or a non-login shell simply run the below command. See the results and find the difference between them. Login shell output will be -bash or -su. Non logins shell output will be bash or su

Conclusion

A Bash shell can be either a login shell or a non-login shell. Both types of shells are invoked with different environment settings. You can easily identify whether a shell is a login shell or a non-login shell with the echo $0 command. In simple terms, when we log in to a Unix-like system with a user, the first shell is the login shell.

Difference Between Login Shell and Non Login Shell   TecAdmin - 45