Basic linux knowledge and basic linux knowledge
1) display command history
Commands run in linux are saved in the. bash_history file of the user's home directory. By default, 1000 Command records are saved.
History displays command history
!! Run the previous command
! N: Execute the nth command.
! Ls executes the last command starting with ls
2) wildcard and other characters
* Matches the prefix with zero or multiple characters.
+ Match the prefix with one or more characters
? Match any 1 Character
# Comments
\ Escape character, \ followed by a common character
! $ The last variable in the previous command
~ User home directory, user home directory, root user home directory:/root, common user home directory:/home/username
& Put commands in the background for execution
Redirection symbol
> Redirect general information and overwrite it to a file> redirect general information and append it to a file
2> redirect error information and overwrite it to the file 2> redirect error information and append it to the file
[] Character or number combination, select a character or number from the range
; Command 1; command 2 command 1 and command 2 need to be executed
& Command 1 & command 2 after command 1 is successfully executed
| Command 1 | command 2, which is executed after command 1 fails
3) variables
Shell variables are generally in upper case. You can use the env command to view the environment variables and the set command to view all the variables in the system.
PATH directory for storing the running program
HOME user's HOME directory
HISTSIZE history Command records
LOGNAME
HOSTNAME Host Name
SHELL user's shell Type
LANG configuration file storage directory
MAIL storage directory
PWD Current Directory
In/etc/profile, set the variable, which can be used by all login users.
In the. bashrc file in the user's home directory, set the variable. This variable can only be used by this user
Variable definition: Variable = variable value. There cannot be spaces on both sides of the equal sign. The variable name can only contain letters, numbers, and underscores, and cannot start with a number. The variable contains special characters, you need to add single quotation marks (''). If the value contains single quotation marks, you need to add double quotation marks (" "). If the value is a command, you need to use reverse quotation marks ('') wrap up.
Common system configuration files:
. Bash_profile: this file is executed once upon logon. It can be understood as a global variable configuration file.
. Bashrc: a user-specific file. Every time you log on to and open the shell, you can execute the file as follows: the variable configuration file for the user.
. Bash_history file that records historical commands
When. bash_logout exits shell, execute this file