Skip to content
Related Articles

Related Articles

Improve Article
Different Ways to Check Which Shell You are Using on Linux
  • Difficulty Level : Easy
  • Last Updated : 28 Mar, 2021

A shell is a program through which users can interact with the Operating System. Linux provides commonly 4 types of Shell The Bourne Shell ( /bin/sh or /sbin/sh ), The C shell ( /bin/csh ), The Korn Shell ( /bin/ksh ), The GNU Bourne-Again Shell ( /bin/bash ). This article is about to Check that which shell we are using. Here, we discuss five ways by which we can check which shell we are using.

1) Using echo command: Basically, the echo command is used to print the input string, but it is also used to print the name of the shell which we are using with the help of the command.

$ echo "My Shell name is: $SHELL"

Ways to Check Which Shell You are Using on Linux

2) Using ps command: ps command stands for “Process Status”. It is used to check the currently running status and their PIDs. If the ps command is run generally in the shell then it simply tells the name of the shell.

$ ps
Ways to Check Which Shell You are Using on Linux

2. Shell name using ps

The first column tells the PID and the last column tells the type of shell i.e. bash.



3) By viewing /etc/passwd file: This tells the feature of the user just like it’s name, shell, and ID. This command is used with the grep command.

$ grep "^$USER" /etc/passwd

Ways to Check Which Shell You are Using on Linux

4) Using lsof command: lsof stands for LIST OF OPEN FILES. This command used when we want the list of open files in our system. By using the specific flag it gives a pointer to the shell and tells us about that which shell are we using and that specific flag is -p $$. The command looks like.

$ lsof -p $$

As you can see clearly in the 3rd line it tells us about the shell we are using.

5) Using readlink /proc/$$/exe: The readlink is used to print the file name. So with the help of this, we print the location of the current shell using the /proc/$$/exe. Command can be written as

$ readlink /proc/$$/exe

Ways to Check Which Shell You are Using on Linux

My Personal Notes arrow_drop_up
Recommended Articles
Page :