In this article, we cover how to identify current shell in Ubuntu. A shell basically acts as a command-line interpreter between us and the operating system. There are different types of Shell – BASH, KornShell, tcsh, Z shell etc.
Every shell is different in its own way. And, if we don’t know the shell we are working on then it would troublesome for us to get our work done. Although there are many ways to identify a shell. The command-line tool which we utilize here is ps.
The ps command helps us extract information about active processes. Apart from that, we will use $$ parameter. The shell mainly stores the Process ID (PID) value of a process that is executing it in $$ parameter. So, the combination of these would help us get the desired outcome.
Identify current shell in Ubuntu
If we provide the PID of any process with ps command then, it would display relevant information about it –
So, for instance if we want to get information about a process – PID – 434 then it would be –
But, what if we replace PID with $$ parameter? Then, it would certainly get us information about current shell. So,
For us the output was –
PID TTY STAT TIME COMMAND 4465 pts/0 Ss 0:00 /bin/bash
Clearly, it was BASH. We have checked the above command for – BASH, KornShell, tcsh, Z shell and Bourne Shell.
In conclusion, we have covered how to identify current shell in Ubuntu through ps command-line tool and $$ parameter.
Additional Info –
This is about getting the PID of a process running in the background. We have covered how to send processes in the background in the article. We will be using ampersand (&) at the end of the command to send it to background –
nano test &
To get PID of the background process, we can use –