Variables and environment variables

Source: Internet
Author: User

1. Get the Process ID number:

(assuming that an application called Gedit is running, you can use the Pgrep command to get the gedit process ID)

$ pgrep gedit12501
2. View environment variables for runtime processes
cat/proc/$PID/environ
3. Get the string length
length=${#var}
4. Identify the shell that is currently in use
Echo $SHELLecho
5. Check if you are a superuser

The UUID is an important environment variable that can be used to check whether the current script is running as a superuser or as a normal user

If [$UID-ne 0]:then echo Non root user. Please run as Root.else echo Root Userfi
6. Modify bash prompt string ([email protected]:~$)

You can use the PS1 environment variable to customize the hint text, the default shell hint text is set in the file ~/.BASHRC, view a row by the following command

$ cat ~/.BASHRC |grep PS1 ps1= ' ${debian_chroot:+ ($debian _chroot)}\[email protected]\h:\w\$ '

If you want to set a custom prompt string

[Email protected]:~$ ps1= "prompt>" prompt> Type commands here


Variables and environment variables

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.