Unit II
Shell
A Shell is a program in Linux that acts as an interface between the user and the operating system kernel.
It allows users to interact with the system by entering commands.
Shell interprets the commands and tells the OS what to do.
It can also run scripts (a series of commands in a file) to automate tasks.
Types of Shells in Linux
There are several types of shells available. The most common ones are:
Shell Name Description Command to Start
Bourne Shell (sh) Original UNIX shell, simple and fast. sh
Bash (Bourne Again Shell) Most common Linux shell; improved version of sh. bash
C Shell (csh) Syntax similar to C programming. csh
Korn Shell (ksh) Combines features of sh and csh; good for scripting. ksh
Z Shell (zsh) Advanced shell with lots of features and customization. zsh
Basic shell configuration files
Configuration Files
Text files used to configure the operating system or applications.
They define parameters, environment settings, startup options, etc.
Usually edited manually with a text editor (like vi, nano, or gedit).
Directory Description
/etc Main directory for system-wide configuration files.
~/.config/ User-specific config files (in the home directory).
/boot Boot loader config files (e.g., GRUB).
/etc/profile
The /etc/profile file is a system-wide configuration file in Linux that sets environment
variables and startup programs for all users using Bourne-compatible shells
It is executed when a user logs in through a login shell
It sets default environment settings like PATH, EDITOR, and other shell variables.
It also calls other scripts from /etc/profile.d/.
It runs once at login (not every time you open a terminal).
Affects all users on the system.
/etc/bashrc
It is a system-wide configuration file for the Bash shell.
Applies to all users.
Typically runs for interactive non-login shells (like when opening a new terminal window or
tab in a GUI).
Purpose of /etc/bashrc
Set default environment variables
Define aliases, functions, and prompt
Enable color support
/.bash_profile
It's a user-specific configuration file for the Bash shell.
Loaded only once when you log in.
Used to set up environment variables, PATH, run startup commands, and load .bashrc.
/.bashrc
~/.bashrc is a user-specific configuration file for the Bash shell.
It runs every time you open a new interactive non-login shell, like:
Opening a terminal window in a GUI (like GNOME Terminal)
Starting a new Bash session manually (bash command)
~/.bash_history
~/.bash_history is a file in Linux that stores the history of commands entered by the user in
the Bash shell.
Location: Inside the user's home directory (~ means the current user’s home).
Purpose: Saves a list of commands that you typed in the terminal using the Bash shell.
Usage: Lets you recall and reuse previous commands by pressing the ↑ (up arrow) key.