Shell

A Linux shell is a command-line interface that allows users to interact with the operating system by executing commands, running scripts, and managing processes. It acts as a bridge between the user and the systemโ€™s kernel, providing an interactive layer to control and automate tasks.

Types of Shell Logins in Linux

Linux supports four main types of shell logins based on how users access the system and interact with the shell:


1. Login Shell

  • Description: A shell session initiated after logging in through a terminal (e.g., via tty, SSH, or a graphical login manager).
  • Key Characteristics:
    • Loads configuration files like /etc/profile, ~/.bash_profile, ~/.bash_login, or ~/.profile.
    • Used for initializing user environments, setting PATH variables, and running startup scripts.
  • Examples:
    • Logging in via SSH.
    • Logging in directly via a console (tty).

2. Interactive Non-Login Shell

  • Description: A shell session opened from within an already logged-in environment.
  • Key Characteristics:
    • Reads user-specific shell configuration files like ~/.bashrc.
    • Does not process login-specific scripts (~/.bash_profile or /etc/profile).
  • Examples:
    • Opening a terminal emulator from a graphical desktop environment.
    • Using the bash command within an existing shell session.

3. Non-Interactive Shell

  • Description: A shell session used to execute scripts or commands automatically without direct user interaction.
  • Key Characteristics:
    • Reads specific files or environment variables required for execution but skips interactive settings.
    • Commonly used for scripting and automation tasks.
  • Examples:
    • Running shell scripts (bash script.sh).
    • Cron jobs or remote execution commands.

4. Restricted Shell

  • Description: A restricted version of the shell with limited capabilities to enhance security.
  • Key Characteristics:
    • Restricts certain commands, such as changing directories, running executables, or setting environment variables.
    • Typically used in controlled environments like kiosks or guest user sessions.
  • Examples:
    • Using rbash (restricted Bash).
    • Implementing custom limited-access shells.