Wednesday, February 4, 2015

[Quick Tips]: Non Login-shell and Login Shell

Non Login-shell and Login Shell

In Linux world there are two major shell interfaces for someone to interact with the operating system:
  1. Login shell
  2. Non-Login shell
From the other hand, Microsoft Windows operating system does not have that option (well…. you can boot intosafe-mode command line but that’s not intended to be used as a working environment but just as another way to save the day / troubleshooting).
windowscommandline
For Windows users, the GUI (Graphical User Interface) is the primary interface for interaction with the operating system — and this fine by me. I completely understand that some things are easier to be done in a visual perspective, like clicking buttons and stuff rather than typing a bunch of instructions for a compiler: True! However, sometimes there’s a need for a shell — and yes, CLI (Command Line Interface) is still kicking in some tasks — especially if you want to be serious about system administration. So, in Linux, GUI is nothing more than just another program. Normally, when a Linux system boots it prompts you into a Non Login shell and waits for your credentials (username/password) to be given. Then, once you ‘ve successfully logged into the system you are in a Login Shell.
Screenshot-2
Wait what? You say you use Ubuntu or Fedora or OpenSuSE or OpenWhatever and you don’t see a terminal, right? Well, this is due to the fact that most well-known Linux distribution run startup scripts to enable the GUI session from the very beginning. Even more, they tend to automatically logged you in from startup. I am pretty sure that Arch Linux users have already figured what I am talking about here. Considering that you are already running a modern distro that automatically boots you into a GUI …
…so once you’ve successfully logged in, fire up a terminal (back in classic Gnome 2.x days: Applications >System Tools > Terminal):
Screenshot-drpaneas@archlinux:~
and this is what is commonly called as Non Login Shell, because you have already logged in. As you can see my user-name is drpaneas and I have normal user privileges (pay attention to the dollar sign ‘$’ ). If you completely logout from your GUI session (eg kill X server) or boot into a non-graphical interface (just switch session using CTRL + ALT + F[1=7] keys) you will see something like this:
loginshell
Now, this is what we call as Login shell, because you have not logged in yet (but you are going to). Different scripts may run on Login and Non-Login shells. We will talk about them later in another article here at Unixmen.com
Furthermore, in Linux we have up to 7 different sessions. In order to grant access into them, you can use a common shortcut: CTRL + ALT + F-key (from 1 to 7). For example CTRL + ALT + F2 fires up the second session. In each session you can be a different user also, which means it craves for you credentials first (so the first thing you can say when you change session is that you are in a Login Shell). In order to come back into the normal GUI session, try hitting CTRL+ALT+ F1 (CentOS based distros) or F7 (Ubuntu based).
So, since the desktop is NOT the only interface to interact with the system, there are several GUIs, graphic environments: Unity, KDE, Gnome, XFCE, Mate, E17 etc. This is the beauty of Linux. You are free to use which ever you want — if you want and when you want. For example, webservers do not utilize GUIs at all because there is no reason for such software.
To sum up, there are two different kinds of shells in Linux: Login shell and Non-Login shell. Normally, Linux boots you into a Login shell by default and once you logged in you are into a Non-Login shell. Pretty simple and easy explanation. In the next articles I will talk you about the shell prompts. Until then, may the source be with you!

No comments: