Get the App
SLTechnology News&Howtos  ›  Servers  › 

How does linux view the current shell category

Shulou Source: shulou.com Published: 2022-06-01 17:08:23 09月24日 Update

This article mainly explains "how to check the current shell categories in linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to check the current shell categories by linux".

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

The code is as follows:

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

(note: $$represents the process number of shell)

2. The most commonly used command to view shell, but it cannot reflect the current shell in real time.

The code is as follows:

$echo $SHELL

3. More concise, but not all shell supports it

The code is as follows:

$echo $0

4. Matching search of shell in environment variables

The code is as follows:

Env | grep SHELL

5. Matching search of shell in password file

The code is as follows:

Cat / etc/passwd | grep muye

6. When using ps-ef

The code is as follows:

$ps-ef | grep $$| grep-v grep | grep-v ps

Note: grep-v means reverse, as follows:

The code is as follows:

Muye@bupt:~$ ps-ef | grep $$

Muye 4750 4745 0 15:47 pts/1 00:00:00 bash

Muye 5331 4750 0 16:51 pts/1 00:00:00 ps-ef

Muye 5332 4750 0 16:51 pts/1 00:00:00 grep-color=auto 4750

Get rid of the last two

At this point, I believe you have a deeper understanding of "how to view the current shell types of linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Code category content real-time process learning practical deeper concise two interest variable password command practical practical commonly used simple operation file method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info OPPO Reno Docker NVidia