The role of shells in the Linux environment

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to: navigation, search
← Shell commandsHomeOther standard shells →

Shell is used for various purposes under Linux. Linux user environment is made of the following components:

  • Kernel - The core of Linux operating system.
  • Shell - Provides an interface between the user and the kernel.
  • Terminal emulator - The xterm program is a terminal emulator for the X Window System. It allows user to enter commands and display back their results on screen.
  • Linux Desktop and Windows Manager - Linux desktop is collection of various software apps. It includes the file manger, the windows manager, the Terminal emulator and much more. KDE and Gnome are two examples of the complete desktop environment in Linux.

Login

User can login locally into the console when in runlevel # 3 or graphically when in runlevel # 5 (the level numbers may differ depending on the distribution). In both cases you need to provide username and password. Bash uses the following initialization and start-up files:

  1. /etc/profile - The systemwide initialization file, executed for login shells.
  2. /etc/bash.bashrc - The systemwide per-interactive-shell startup file. This is a non-standard file which may not exist on your distribution. Even if it exists, it will not be sourced unless it is done explicitly in another start-up file.
  3. /etc/bash.logout - The systemwide login shell cleanup file, executed when a login shell exits.
  4. $HOME/.bash_profile - The personal initialization file, executed for login shells.
  5. $HOME/.bashrc - The individual per-interactive-shell startup file.
  6. $HOME/.bash_logout - The individual login shell cleanup file, executed when a login shell exits.
  7. $HOME/.inputrc - Individual readline initialization file.

Bash Startup Scripts

Script of commands executed at login to set up environment. For example, setup JAVA_HOME path.

Login Shell

Login shells are first shell started when you log in to the system. Login shells set environment which is exported to non-login shells. Login shell calls the following when a user logs in:

Non-Login Shell

Bash Logout Scripts

  • When a login shell exits, bash reads and executes commands from the file $HOME/.bash_logout, if it exists.
← Shell commandsHomeOther standard shells →