• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

What is the difference between Login and Non-Login Shell

Written by Rahul, Updated on April 12, 2020

A shell is an important layer of Linux architecture. Shell is an interface which takes input from Users and sends instructions to the Kernel, Also takes the output from Kernel and send the result back to output shell.

In this tutorial, we use Bash shell for the examples. Basically a shell is of two types, Login Shell and Non Login Shell. Every shell run some set of predefined scripts to configure shell environments.

Login Shell

A Login shell is created after a successful login of user. For example, when you login t a Linux system via terminal, SSH or switch to user with “su -” command.

When a login shell start, it runs a set of predefined script to configure shell environment. To identify the login shell, run the below command on terminal.

echo $0

If you get the result like “-bash” or “-su” means, you are on login shell. Make sure it has hyphen (-) as prefix.

A Login Shell executes following scripts:

  • Login shell executes /etc/profile
  • /etc/profile executes all scripts in /etc/profile.d/
  • Then executes users ~/.bash_profile
  • ~/.bash_profile executes users ~/.bashrc
  • ~/.bashrc executes /etc/bashrc

Non Login Shell

Non Login Shell is the shell, which is started by the login shell. For example, A shell which you started from another shell or started by a program etc.

A non login shell executes the following script to set the shell environment.

  • Non login shell first executes ~/.bashrc
  • Then ~/.bashrc executes /etc/bashrc
  • /etc/bashrc calls the scripts in /etc/profile.d

Check Login vs Non Login Shell

To find the current shell is login shell or non login shell simply run the below command. See the results and find the different between them.

echo $0

Login shell output will be -bash or -su.

Non logins shell output will be bash or su

difference between login shell vs non login shell

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

1 Comment

  1. Avatar Jayesh Reply
    April 25, 2020 at 6:06 am

    Good info Rahul. Thanks

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy