Every Linux system has at least one shell where you can run commands, tasks, processes and shell scripts. Every Linux user is assigned a default shell. When a user opens terminal, they are logged into their default shell. Since there are multiple shells on most Linux systems, it may not be obvious which shell you are using. In this article, we will learn how to find out which shell you are using, how to list all available shells, and how to change your shell.
How to Know Which Shell I am Using in Linux
It is very easy to find out which shell you are using. Just open terminal and run either of the following commands.
# echo $0 OR # echo $SHELL
$0 and $SHELL are system variables that store information about the shell the user is running. If you are using bash shell, you will see output like the following when you run the first command echo $0
-bash
You will see the following output when you run the second command echo $SHELL
/bin/bash
$0 stores the shell name and $SHELL stores the path to the shell.
If you want to list all shells installed on your system, or the ones you have access to, run the following command.
# cat /etc/shells
You will see the following kind of output depending on the shells installed on your system, as well as your access permissions.
# /etc/shells: valid login shells /bin/sh /bin/dash /bin/bash /bin/rbash
If you want to change your default shell, use the chsh command, followed by -s or –shell option, followed by the full path of new shell you want to set as default. Here is the command to set your default shell as csh.
$ sudo chsh -s /bin/csh OR $ sudo chsh --shell /bin/csh
If you want to change the default shell of another user e.g. test_user, just add a space and mention it after the above commands, as shown.
$ sudo chsh -s /bin/csh test_user OR $ sudo chsh --shell /bin/csh test_user
In this article, we have learnt how to find out which shell you are using in Linux, how to list all available shells and how to switch shells. You can run these commands on almost all Linux systems, since they are universally available.
Also read:
How to Find Package Details in RHEL, CentOS, & Fedora
How to Delete Objects in Django
How to Delete File or Folder in Python
How to Disable Django Error Emails
How to Find Files with Special Characters in Filename in Linux
Related posts:
Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.