sudo <command> < arguments> equivalent to root permission execution command
Give executable permissions to all user files: chmod a+x script.sh
Execute script:
./script.sh#./represents the current directory
Command 1:echo "Welcome to Bash"
Command 2:printf "Hello World"
Difference: printf does not carry a newline!
Example1:
#!/bin/bash
printf "%-5s%-10s%-4s\n" No Name Mark
Command 3: View environment variables when the process is running:
cat/proc/$PID/environ (PID is the ID of the process)
Command 4: Get the ID of the process
Pgrep gedit
12501 (ID of the gedit process)
You can view the environment variables for a process by using the following command:
Cat/proc/12501/environ/gdm_keyboard_layout=usgnome_keyping=1560user=slynuxhome=/home/slynux
Change command to return a list containing environment variables and corresponding variable values
Command 5:tr ' \ n ' to replace command
Attention:
Var=value is an assignment operation, var = value is an equal operation, error prone;
Example:
Var= "Value"
echo $var (output content, using $ symbol)
The latter echo ${var}
Environment variables are variables that are not defined in the current process and are inherited from the parent process;
To add a new path in path:
Export path= "$PATH:/home/user/bin"
You can also use:
Path= "$PATH:/home/user/bin"
Export PATH
Shell Script Learning 1 (Linux script Raiders)