Shell is a command interpreter. It interprets the commands entered by you, runs against Unix/Linux Kernel, and provides the result on the standard output device. There are many shells developed since Unix came into existence.
Below is the list,
- Bourne Shell – sh
- C Shell – csh
- T Shell – tcsh
- Korn Shell – ksh
- Bourn-again Shell – bash
- Dash Shell
- Z shell
Oho… there are many. Which shell are you using?
In this article, we will provide a comprehensive guide to identify the shell in use.
Which Shell am I Using?
There are multiple method using which you can find out the shell you are using. We are covering 3 methods below.
Either should work for you, but you should know all.
1. /etc/passwd file
Unix creates all required configuration and setup when a user is created. Run grep <user> /etc/passwd to know the shell which you are using when you log in to Unix or Linux operating system.
Here, <user> – login user name.
The below example answers the question,
grep imaginelinux /etc/passwd
Here, you are using Bourne – sh shell.
2. Another way is by using the $SHELL variable.
$SHELL variable is set with the default shell name as soon as you log in. Just display the content of the variable using the echo command to find out the default shell.
You can also use $0 as well to find out shell. This is special variable and is set at shell initialization. It stores name of the shell.
3. ps -p $$
Another method is to use the ‘ps’ command with the ‘-p’ flag, followed by ‘$$’. This command will display information about the current shell’s process, including its name.
ps -p $$
Now you know the shell. What if you want to change it?
That is also possible.
Linux provides ‘chsh’ (change shell) command that allows you to update the default shell for your user account. For example, to switch to Zsh, execute the following command:
chsh -s /bin/zsh
Different shells have different features, syntax, and built-in commands. Knowing your shell is essential for understanding its features and capabilities, as well as customizing your command-line experience. It also helps when looking up documentation or tutorials specific to your shell.
Just read below article go get more information on this topic.
You can learn more about shell by running man <shell name> command on terminal e.g man sh.
That’s it. I hope you liked this small tip.
Please share and like.