How to view the current shell in linux

Source: Internet
Author: User
This article mainly introduces how to view the current shell in linux. For more information, see

1. view the shell types used in the current process in real time: recommended

Copy codeThe code is as follows:
Ps | grep $ | awk '{print $4 }'

(Note: $ indicates the shell process number)

2. the most common command for viewing shell, but it cannot reflect the current shell in real time

Copy codeThe code is as follows:
$ Echo $ SHELL

3. more concise, but not all shells support

Copy codeThe code is as follows:
$ Echo $0

4. search for shell matching in environment variables

Copy codeThe code is as follows:
Env | grep SHELL

5. search for shell matching in the password file

Copy codeThe code is as follows:
Cat/etc/passwd | grep muye

6. when using ps-ef

Copy codeThe code is as follows:
$ Ps-ef | grep $ | grep-v grep | grep-v ps

Note: grep-v indicates inverse, as shown below:

Copy codeThe code is as follows:
Muye @ bupt :~ $ Ps-ef | grep $
Muye 4750 4745 0 00:00:00 pts/1 bash
Muye 5331 4750 0 00:00:00 pts/1 ps-ef
Muye 5332 4750 0 00:00:00 pts/1 grep -- color = auto 4750

Remove the last two

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.