Which shell am I using?

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

run grep on /etc/passwd to find out shell

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.

echo $SHELL

echo $Shell to see shell information

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.

echo $0

echo on $0

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 $$

ps -p $$ to check shell name

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
You may need to log out and log back in for the changes to take effect.

Summary

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.

4 thoughts on “Which shell am I using?”

    1. It may not matter in normal case. Most of the Linux User even does not know or care about it.

      Each shell exhibits unique characteristics, syntax, and innate commands. Identifying your shell type can assist in developing scripts or commands suitable for that specific shell environment.

      For example, zsh has powerful plugins and themes, while bash is known for its wide compatibility and adoption. The best way to understand the differences is to explore each shell or read their respective man pages

  1. Thanks for the article.

    I think Linux comes with multiple shell by default and you can also install new shell if you want.

    How to check total number of shells installed on any Linux Distribution?

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top