Linux Current Shell Summary!

Source: Internet
Author: User

Task handover, different systems, versions, and shells may not be the same. Some time ago to help a friend to engage in centos5.9, ya ya the use of incredibly is sh. It's crazy! Make a brief summary.

View the shell supported by the current system

[Email protected] ~]# Cat/etc/shells

/bin/sh

/bin/bash

/sbin/nologin

/bin/dash

[Email protected] ~]#

Note: You can install other shells yourself. Like Zsh.


View the shell that is currently in use by the system

1. Echo

I like to use the way, but This usage is not supported by all shells.

[Email protected] ~]# Echo

-bash

[Email protected] ~]#

2. Echo $SHELL

The most common command to view the shell, but not to reflect the current shell in real time. For example, you cannot display the child shell that is located.

[Email protected] ~]# echo $SHELL

/bin/bash

[[Email Protected]ode6 ~]#

3. Real-time view of the shell used in the current process

[[Email protected] ~]# PS | grep $$ | awk ' {print $4} '

Bash

[Email protected] ~]#

Or:ps-ef | grep $$ | Grep-v grep | Grep-v PS

(Note: $$ indicates the shell's process number)

4.


When you know the shell, you can view its version:

[Email protected] ~]# bash-version

GNU Bash, version 4.1.2 (1)-release (X86_64-REDHAT-LINUX-GNU)

Copyright (C) Software Foundation, Inc.

License gplv3+: GNU GPL version 3 or later


This was free software; Redistribute it.

There is NO WARRANTY, to the extent permitted by law.

[Email protected] ~]#


Special variables in the shell:

$

The name of the shell or shell script

$*

Give the argument list in pairs of double quotes

[Email protected]

Double quotation marks to return each parameter

$#

Number of parameters

$_

Represents the last parameter of the previous command

$$

PID that represents the command that is located

$!

PID that represents the last executed background command

$?

Represents the exit status after the execution of the previous command



--Ningzhiyuan Experience Summary

This article from the "[email protected]" blog, reproduced please contact the author!

Linux Current Shell Summary!

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.