Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Tutorials»What is the difference between Login and Non-Login Shell

    What is the difference between Login and Non-Login Shell

    RahulBy RahulApril 12, 20202 Mins Read

    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

    bash linux shell
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install Docker on CentOS/RHEL 8
    Next Article How To Install Gradle on Fedora 35/34

    Related Posts

    (Resolved) userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms

    Updated:May 10, 20221 Min Read

    How to Install Apache ActiveMQ on Ubuntu 22.04

    3 Mins Read

    How To Enable SSH Server on Ubuntu 22.04

    Updated:April 22, 20222 Mins Read

    How To Install LAMP Stack on Ubuntu 22.04 LTS

    Updated:April 20, 20225 Mins Read

    How to Backup Website to Amazon S3 using Shell Script

    Updated:March 24, 20222 Mins Read

    Bash Printf Command

    Updated:December 23, 20212 Mins Read

    1 Comment

    1. Jayesh on April 25, 2020 6:06 am

      Good info Rahul. Thanks

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.