How to check which shell is used under Linux
This article mainly explains "how to check what kind of shell is used under Linux". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to check which kind of shell is used under Linux".
View the shell available for the current release
The code is as follows:
[root@localhost ~] $cat / etc/shells
/ bin/sh
/ bin/bash
/ sbin/nologin
View the shell method currently in use
First, the most commonly used command to view shell, but can not reflect the current shell in real time
The code is as follows:
[root@localhost ~] $echo $SHELL
/ bin/bash
The following usage is not supported by all shell
The code is as follows:
[root@localhost ~] $echo $0
-bash
Third, the matching search of shell in environment variables
The code is as follows:
[root@localhost ~] $env | grep SHELL
SHELL=/bin/bash
4. Matching search of shell in password file
The code is as follows:
[root@localhost ~] $cat / etc/passwd | grep root
Root:x:0:0:root:/root:/bin/bash
View the current process
The code is as follows:
[root@localhost ~] $ps
PID TTY TIME CMD
3052 pts/0 00:00:00 bash
3254 pts/0 00:00:00 ps
6. Check the pid of the current shell before navigating to the shell process
The code is as follows:
[root@localhost ~] $echo $$
1862
[root@localhost ~] $ps-ef | grep 1862
Root 1862 1860 0 01:50 pts/0 00:00:00-bash
Root 2029 1862 0 02:07 pts/0 00:00:00 ps-ef
Root 2030 1862 0 02:07 pts/0 00:00:00 grep 1862
7. Enter a command that does not exist to view the shell prompt for errors
The code is as follows:
[root@localhost ~] $asdf
Bash: asdf: command not found
Attachment: it can be realized with one command:
The code is as follows:
[root@localhost ~] $ps-ef | grep `echo $$`| grep-v grep | grep-v ps
Root 1862 1860 0 01:50 pts/0 00:00:00-bash
Thank you for your reading, the above is the content of "how to check which kind of shell is used under Linux". After the study of this article, I believe you have a deeper understanding of how to check which kind of shell is used under Linux. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!