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