View the currently used shell

Source: Internet
Author: User

PS |  grep $$ | awk ' {print $4} '

PS command without parameters displays the status of the process associated with the current terminal
$$ variable stores the PID of the current process
PS Fourth column is the command used by the process, if it is a shell, then display the shell name, such as Sh/ksh, etc.
awk ' {print $4} ' is only showing the value of column fourth


PS: Use echo $SHELL to view the system's default SHELL

View the shell that the current release can use
[Email protected] ~]$ Cat/etc/shells
/bin/sh
/bin/bash
/sbin/nologin

View the currently used shell
One, the most common command to view the shell, but cannot reflect the current shell in real time
[Email protected] ~]$ echo $SHELL
/bin/bash

Second, the following usage is not supported by all shells
[Email protected] ~]$ Echo
Bash

Third, the shell matching search in environment variables
[Email protected] ~]$ env | grep SHELL
Shell=/bin/bash

Four, the password file in the shell matching search
[Email protected] ~]$ CAT/ETC/PASSWD | grep, Jack.
Jack:x:500:500:mengfei:/home/jack:/bin/bash

V. Viewing the current process
[[Email protected] ~]$ PS
PID TTY Time CMD
3052 pts/0 00:00:00 Bash
3254 pts/0 00:00:00 PS

Six, first view the current shell PID, and then navigate to this shell process
[Email protected] ~]$ echo $$
3052
[Email protected] ~]$ Ps-ef | grep 3052
Jack 3052 3047 0 11:33 pts/0 00:00:00 bash
Jack 3420 3052 0 11:57 pts/0 00:00:00 ps-ef
Jack 3421 3052 0 11:57 pts/0 00:00:00 grep 3052

Attached: One command can be implemented:
[Email protected] ~]$ Ps-ef | grep ' echo $$ ' | Grep-v grep | Grep-v PS
Jack 3052 3047 0 11:33 pts/0 00:00:00 bash


Enter a non-existing command to see the shell prompt for the error
[Email protected] ~]$ Tom
Bash:tom:command not found

Original posts: http://rickie622.blog.163.com/blog/static/212388112011213407503/

View the currently used shell

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.