Linux Shell and Command Types Explained

This tutorial explains how to view the current shell, list all available shells, change shell temporary or permanently along with Linux command types; internal, external, privileged and non-privileged in detail. Learn what the Linux command, option and argument are and how they work with examples.

This tutorial is the second part of the article \”Linux file system and shell explained with file redirectors\”. It explains following RHCSA/RHCE objective.

Access a shell prompt and issue commands with correct syntax

Other parts of this tutorial are following.

Linux file system and kernel version explained

This tutorial is first part of the article. It explains Linux file system structure (Linux directory structure) in detail along with naming convention used in kernel name.

STDIN, STDOUT, STDERR and File redirectors explained

This tutorial is the third part of the article. It explains what the STDIN, STDOUT, STDERR and File redirectors are and how they work in Linux with examples.

The shell is the default working environment in Linux. It accepts commands, interprets and processes those commands and returns the result on desired location. Different shells such as ksh, sh and bash are available in Linux.

Login process identifies the user and based on customization, it presents the configured shell just after the login.
If no customization is available for that particular user, it presents the default shell. In RHEL, default shell is the bash.

If user is logged in text environment, no further action is required to access the shell. Shell is ready to use just after the login. But if user is logged in GUI environment, in order to access the shell, he or she has to open a terminal box. Opening terminal box is simple and straightforward.

To open a terminal box, right click and select \”Open Terminal\” from right click context menu.

open terminal box in linux

Shell command prompt

Shell uses two types of command prompt:-

  • For regular user, it uses a command prompt that ends with $ character
  • For super user, it uses a command prompt that ends with # character

By default both prompts provide information about username, hostname and current working directory.

difference between regular user and root user command prompt

Shell practical examples for practice

Login from a regular use account and perform following task: –

  • View the current shell and list all available shells.
  • Change current shell temporary for running login session and verify the change.
  • Logout from current session and login again to verify that default shell has been restored.
  • Change shell again, but this time change it permanently.

Viewing the current shell and listing all available shells

To view the current shell, use echo $0 command. To list all available shells, either use cat /etc/shells or use chsh –l command.

how to view the current shell and list all available shell

Changing shell temporary

To change current shell temporary, use exec /bin/csh command. This command will change current shell to csh.
This change will be temporary. It will be lost with the current session. To verify this, terminate the current session with exit command.

Login again and view the current shell. It will be restored back to the default shell.

how to change shell temporary

Changing shell permanently

To change the current shell permanently, use chsh –s /bin/csh command. Change will take place at next login.

how to change shell permanently

Command Description
cat /etc/shells To list the all available shells
chsh –l To list the all available shells
echo $0 To view the current shell name
exec /bin/csh To change current shell temporary. At next login default shell will be restored.
chsh –s /bin/csh To change current shell permanently. Change will be applied at next login. Default shell will be used in current session.

Linux command types

A Linux command is basically a link of an executable file. Location of the file decides the type of command.
If executable file is available with in shell then the command is considered as an internal command.
If executable file is available outside the shell then it is considered as an external command.

If command is internal, shell will execute it immediately. If command is external, shell will search the
executable file in specified locations. If shell finds a match, it will run that file. Otherwise it will return with error message \”command not found\”.

  • To know whether a command is internal or external we can use type command with –t option.
  • If command is external, we can use which command to know the location of the executable file.
  • To know the path where shell will search for the executable files, we can use echo $PATH command.

linux command types internal and external

Like location, commands can also be categorized on the basis of privilege.

Every file in Linux is secured with permission levels. These permission levels define who are
allowed to access the file and how they are allowed to access it. When shell accesses an executable file,
it reads the permission properties of that file and decides whether the user who is trying to execute that file
has the necessary permission to do this or not. If user has the permission, shell executes the file otherwise
it asks user to provide the necessary credentials. If user fails to provide the necessary credentials, it does not execute the file.

linux command types privileged and non-privileged

Linux command types
Criteria Type Description
Location Internal These commands are integrated in shell. These commands are usually used for regular data manipulation tasks.
External These commands are not the part of the shell. These commands are either installed by Linux or third party software for specific services or tasks.
Privilege Non-privileged These commands are used for regular tasks and do not require any special privileges to run. These commands are available for both types of user account; regular and root.
Privileged These commands are available only for root (super user) account. These commands are intended for system management and require special privileges to run.

Linux command syntax

Basic syntax for a Linux command is following.

command option argument

Let’s understand each parameter in detail.


Command is the link of an executable file. After entering any keyword at shell prompt when we hit the Enter key,
shell finds an executable file matching with that keyword. If file is available, shell executes that file otherwise
it returns an error message \”Command Not Found\”.


Option is a single letter or a word, preceded by a hyphen sign that is used to change the behavior of command.
A command may use single option or multiple options or no option at all. Options can be used independently or jointly.
Regardless how they are used, they are interpreted separately. To group the options, remove space and hyphen from all options and
add a single preceding hyphen only before the first option.

option parameter in linux command

To use a whole word as option, usually commands use double hyphen. This convention removes unnecessary confusion between single
word option and grouped single letter options.

For example, usually commands use –help option to provide the basic information about them. If we use a single hyphen, shell
will interpret all letters individually (-h–e–l-p). If it fails to execute the command with interpreted options only then it
will execute the command by assuming all options as a single option (-help).

If a command supports single word option with single hyphen, it will execute. Otherwise it will return with an error message \”invalid option\”.
Again error message will be displayed for the first unmatched option.

option in linux command explained

Shell processes options based on hyphen signs. If there are two preceding hyphens, following letters will be treated as a single word.
If there is a single preceding hyphen, following letters will be treated as individual options.

how to use option with linux command


Argument is the keyword which specifies the target where command performs the action.
It can be any supportive information such as filename, directory, device or username. A command may accept single argument or
multiple arguments or no argument. Arguments are limited by the total allowed numbers of the character at command line.

Shell allows us to combine arguments with options to get more specific result. If argument is going to be used with a single
letter option, add a space between option and argument. If argument is going to be used with word option, add an equal (=) sign between them.

how to use argument in linux command

That’s all for this part. In next part, we will understand I/O (Input / Output)
redirection in detail with examples. If you like this tutorial, please don’t forget to share it from your favorite social platform.

Full Version EX300 Dumps

Try EX300 Dumps Demo