Skip to content
Linux TLDR
  • 🏠 Home
  • 🐧 Topic
    • All in One
    • DevOps
      • Ansible
      • AWS
      • Docker
      • Git
      • Jenkins
      • Kubernetes
    • Hardware
      • Raspberry Pi
    • How to
    • Linux Commands
      • Builtin Commands
      • Curl Commands
      • Homebrew Commands
      • MySQL Commands
      • SSH Commands
    • Linux Distributions
      • Alma Linux
      • Debian
      • Fedora
      • Kali Linux
      • Linux Mint
      • Manjaro
      • Red Hat
      • Ubuntu
    • News & Updates
    • Package Installer
    • Programming
      • Bash Scripting
      • C/C++
      • Go Lang
      • Java
      • Javascript
      • Node Js
      • Php
      • Python
      • Ruby
    • Reviews
    • Tools
    • Troubleshooting
    • Tutorials
    • Weekly Roundup
    • What is
  • 🕵️ Privacy Policy
  • 📧 Contact Us
  • 📖 About
    • 🪶 Write an Article
    • 🔗 Follow Us
    • 🎁 Donate

What is Login Shell in Linux?

Linux TLDR
Last Updated: January 4, 2024
Reading time: 3 minutes

The “login shell” is a term used to define which shell (like Sh, Bash, or Zsh) will be used to load the environment variables and shell configuration files when you log into an interactive session.

💡
Once you log into your system using a pre-defined login shell, you can switch to another shell (as a subshell) from your interactive shell.

So, you can consider it the first process that starts with your system and runs under your user ID when you interactively log in to your system (like system boot, “su -” command, or SSH to remote system will get you in interactive login shell).

To fully comprehend the login shell in Linux, you must be familiar with how users get authenticated during system boot, interactive and non-interactive logins, and shell configuration files.

If you want a thorough grasp of the Linux login shell, read this article all the way through.

Table of Contents

Toggle
  • How Users Get Authenticated on System Boot in Linux
  • Interactive Login vs Non-Login Shell
    • Interactive vs Non-interactive shell
    • Login vs Non-login shell
  • How to Verify You Are in the Login Shell
  • Final Tips!

How Users Get Authenticated on System Boot in Linux

As you know, Linux is a multi-user operating system where multiple users can login and use the system at the same time.

To protect your system from unauthorized access, the getty program (short for “get tty“) is the first process that runs when your (init or systemd) system boots up.

The role of the getty program is to prompt login screen to allow you enter your username and password and then verify the specified information from the “/etc/passwd” file.

All the users and system account information is stored in “/etc/passwd” file like username, UID, GID, comments, home directory, and your default login shell.

"/etc/passwd" file

As shown in the preceding image, the last column is used to define the user login shell, which is the first program that runs when a user logs in.

If the last column is empty, the “/bin/sh” shell will be used by default as the user login shell.

Interactive Login vs Non-Login Shell

Now you understood that the “/etc/passwd” file store the users and system account information including user login shell.

Next, you need to understand the difference between the interactive login and non-login shell; although we have written a detailed guide on this topic, we will still give you a small overview.

So, let’s look at the difference between an interactive and a non-interactive shell:

Interactive vs Non-interactive shell

  • Interactive shell: can be said to be when you directly interact with your shell from the command line.
  • Non-interactive shell: can be said to be when you indirectly interact with your shell, like shell script.

Next, let’s look at the difference between a login and a non-login shell:

Login vs Non-login shell

The “login shell” is the first process that runs under the user ID after the system boots or when the “su -” command is executed. Even if you use SSH to connect to a remote system, it will be seen as an interactive login shell.

Aside from that, login-shell will load some configuration files (or profiles), such as “/etc/profile” and “~/.bash_profile” for Bash and “/etc/zprofile” and “~/.zprofile” for Zsh, into your current shell environment.

For example, I’ve edited a few of the configuration files and commented out their filenames to demonstrate how these files were loaded when you launched login-shell (via SSH).

Login shell

This file will only be read and run in your current shell environment once, when your system boots up. After that, you’ll interact with a non-login shell.

The “non-login shell” is when you start more than one shell in the same environment after the system boots. For example, you could run the bash command in your terminal or open a new tab in your terminal.

Non-login shell

The non-login shell originates from the login shell, due to which it will get all the environment variables set by the login shell via the profile files. Although, the non-login can define their own environment variables through rc (resource configuration) files.

For the bash shell, it is usually “/etc/bash.bashrc” and “~/.bashrc” files, while for the zsh shell, it is “/etc/zshrc” and “~/.zshrc“.

How to Verify You Are in the Login Shell

The login shell and non-login shell can be easily identified, especially if you are using the Bash shell. So, if you are using the login shell, then the “-” character is prepended to the shell executable (ex: “-bash“), while for the non-login shell, it would normally be “bash“.

📝
When you log in to graphical mode on a desktop Linux computer, a display manager controls it. This time, you won’t get a login shell; instead, you’ll get a session manager or a window manager.

Or you can execute the following command to check whether you are using the login or non-login shell:

$ echo $0

Output:

Verifying the login and non-login shell

Final Tips!

Although, this article gives you a grasp on Login Shell, I also strongly recommend that you visit the referenced links in this article to learn more about them.

If you have any questions or problems while understanding any point, feel free to ask them in the comment section.

SHARE:

Recommended Articles

🔗How to Install Zabbix Server on Ubuntu 24.04 (Noble Numbat)
🔗Stellar Repair for MySQL – Product Review
🔗How to Install RQuickShare (NearbyShare/QuickShare) on Linux
🔗How to Install RabbitMQ Server on Linux (Quick Guide)
🔗How to Use Chattr Command in Linux (for Beginners)
🔗How to Setup SOCKS5 Proxy Server on Linux Using MicroSocks
🔗Reset the WordPress Admin Password Using CLI (via 2 Methods)
🔗How to Check Python Version in Linux (via 3 Methods)
🔗How to Check PHP Version in Linux (via 4 Methods)
🔗[Fixed] pkg-config script could not be found in Linux

Latest

Install zabbix server on ubuntu

How to Install Zabbix Server on Ubuntu 24.04 (Noble Numbat)

mysql database recovery tool

Stellar Repair for MySQL – Product Review

RQuickShare Linux

How to Install RQuickShare (NearbyShare/QuickShare) on Linux

Install RabbitMQ Server on Linux

How to Install RabbitMQ Server on Linux (Quick Guide)

chattr command

How to Use Chattr Command in Linux (for Beginners)

Newsletter

Explore the latest Linux news, tutorials, tips, and resources to master open-source technology.

Social Handles

quora

Your help is needed

AI and ad blockers are significantly impacting advertising revenue. Donate now to support funding for this independent site.

🎁 Make a Donation
Linux TLDR © 2026 - Discover, Learn, and Master Linux with Us 🐧