Linux-shell basics-shell
1: The user's shell History commands are saved in home/username/. bash_history
#!!
Execute the user's previous command
#! Pw
The last command starting with pw in the execution history
2: '*' to match zero or multiple characters
'? 'Match one character
# Ls-d Day * lists directories with names starting with Day and matching all characters
# Ls-d Day? List directories that start with Day and match with one character
3:> append redirection to a file
> Retargeting in files
4: | MPs queue Operator
# Cat/etc/passwd | wc-l
The output of cat/etc/passwd command is used as the wc command input. Count the number of passwd rows
5 ctrl + z command to pause a task
# Jobs:
(My-env) [flex @ localhost linux_learn] $ jobs
[1] + Stopped vim test1.txt
# Fg + id can resume operation
# Bg + id: This task can be run in the background
# Ps aux | grep test1 can view the pid of the process running in the background
# Kill-9 pid can end this process
6 $ PATH
PATH when you enter the command, LINUX will find the PATH recorded in the PATH.
For example, you can enter the ls command in the root directory,
You can also enter ls in the/usr directory,
But in fact, the ls command is not in these two directories at all.
In fact, when you enter the command, LINUX will go to/bin,/usr/bin,/sbin and other directories to find the command you entered at this time,
The value of PATH is/bin:/sbin:/usr/bin:
The colon separates directories from directories.
7. The set command can display system preset variables, such as path home, and User-Defined variables.
# Myname = Aming set custom Variables
# Set | grep myname
Myname = Aming
You can view your own Defined variables.
# Bash enters another shell
# Set | grep myname: The Defined variables cannot be viewed. The Defined variables only exist in the defined shell.
7.1 make the Defined variables available to all users
# Sudo vim/etc/profile
Add export myname = Aming
# Source/etc/profile takes effect
7.2 make the Defined variables take effect in all sub-shells
# Abc= 123
# Export abc
7.3 unset the variable
# Unset abc
# Unset myname
8 wc command
# Wc/etc/passwd-l count the number of rows
# Wc/etc/passwd-m count
# Wc/etc/passwd-w count
9 ~ Indicates the user's home directory.
Root under/root
Common users are in/home/username
10 2> indicates redirection of errors
2> indicates an error append redirection.
# Ls aaaa 2>/tmp/error
# Ls aaaa 2>/tmp/error
You can view errors in error