Tag Archives: Shell

What is Shell in Linux?

The Command Line Interface (CLI) is more popularly known as Shell and sometimes also referred to as prompt or terminal. It provides you with a text interface where you can write your command and the Shell will execute the corresponding task. As there are different distributions and flavors of Linux there are also different flavors of Shell. Each flavor has its own specific commands for various tasks and has its own benefits.

The Shell is one of the core features of Linux. You can use it to perform from the simplest of tasks to much complicated tasks.

Types of Linux Shell

Bourne Shell

This shell is fast and simple. However, simplicity means that it has less features than other types of shells. It is suitable for newbies but not experts.

Bash Shell

The Bash Shell, short for Bourne Again Shell, is one of the most popular shells that you may find in many Linux distributions. It provides many features while thriving to be simple.

C Shell

It was created by Bill Joy. It provides many features like aliases and command history for interactive use. Moreover, it also includes features like built-in arithmetic and C-like expression syntax to make programming easier.

TENEX C Shell

It is a modified version of C shell. It has many improvements like better history control, terminal locking, and read only variables. The shell also includes spell check and auto-completion features. Even after these modifications, it is fully compatible with C shell.

Korn Shell

It was developed by David Korn. It includes many features of Bourne shell and C shell. In addition to this, it also has its own unique features that make it even better.

Z Shell

It basically a modified version of Bourne shell. It incorporates features like better option handling, loadable modules and compatibility modes.

Fish Shell

Fish shell, short for friendly-interactive shell, aims to be more user friendly and interactive than any other shell.

Linux shell or the terminal is the lifeline of developers to manage their computer systems and data. Things which can be done on the GUI can be done much efficiently on the terminal by using commands. One can not remember all the commands, but with regular usage, one will be familiar with them. The following guide will introduce you to some basic Linux Shell Commands required to use your Linux system efficiently.

Gnome Terminal

Below, you can see a screenshot of the Gnome terminal application. As you can see the command prompt contains the following information:

 [username@hostname directoryname]  

In our case the username is root, hostname is monitor and directory is /root(~).

Gnome- Linux Shell Commands
Gnome Terminal

A terminal and a shell:

Read the articles on Wikipedia to learn about computer terminals and the shell.

Date command:

The date command shows the current date and time.

$ date 
Tue Jan 22 10:13:44 IST 2019

If you want to see the current date and time in UTC you can run the command as follows:

 $ date -u 
Cal command:

The cal command will display calendar in your shell, by default it displays current month.

 $ cal 
January 2019
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

$cal Feb 2019
February 2019
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28
The whoami command:

This command will let you know the user account to which you are logged in on the shell.

$whoami
root
The id command:

This command returns user id, group id and groups of the current user.

$ id 
uid=0(root) gid=0(root) groups=0(root)
The pwd command:

The pwd command displays absolute path of current directory.

root@monitor:~# pwd
/root
The cd command:

This command will help you change directory on the shell. In the following example we will move to /etc/ directory.

root@monitor:~# pwd
/root
root@monitor:~# cd /etc/
root@monitor:/etc# pwd
/etc
The . directory and .. directory:

. and .. has special meaning in the Linux. i.e . means current directory and .. means parent directory.

root@monitor:/etc# cd .. 

This command will move us to the parent directory.

The ls command:

The ls command will display the files and directories inside the given directory. If you use the ls command without any argument, then it will return the output for the current directory. Here is the example:

root@monitor:/# ls
bin etc key.txt lost+found opt run srv usr
boot home lib media proc sbin sys var
dev initrd.img lib64 mnt root scripts tmp vmlinuz
root@monitor:/# ls home
ansible ssbackup.log ssbackup.py-bak
ec2-automate-backup.sh ssbackup.py ubuntu

In last command, we provided a path as the argument to the ls command.

The mkdir command:

Using the mkdir command you can create new directory. For example , we are creating test directory in home directory.

root@monitor:/home# mkdir test
root@monitor:/home# ls
ansible ssbackup.log ssbackup.py-bak ubuntu
ec2-automate-backup.sh ssbackup.py test

We can also create directories in a recursive way using -p option:

root@monitor:/home# mkdir -p  dir1/dir2/dir3
root@monitor:/home# ls
ansible ec2-automate-backup.sh ssbackup.py test
dir1 ssbackup.log ssbackup.py-bak ubuntu
root@monitor:/home# ls dir1
dir2
root@monitor:/home# ls dir1 dir1/dir2/
dir1:
dir2
 dir1/dir2/:
dir3

We will learn further basic commands in Part II.