First, Shell Foundation
The shell is a command interpreter that provides interaction between the user and the machine
Each user can have their own specific shell
Centos7 default shell is bash (Bourne Agin Shell)
Besides bash, there's zsh.ksh and so on.
Ii. History of the Order
The commands that have been knocked are stored in the/root/.bash_history and can store up to 1000 records.
You can use the history command to view
History-c can erase the history of the command in memory, but cannot clear the command in the config file/root/.bash_history
Echo $HISTSIZE look at the environment variables to see how many commands can be stored.
/etc/profile inside can change the environment variable
Source/etc/profile Refresh profile to make environment variables effective immediately
histtimeformat= "%y%m%d%h:%m:%s" allows history to temporarily display the input time of the historical command
If you want to be effective, add histtimeformat= "%y%m%d%h:%m:%s" line to/etc/profile
Source/etc/profile Refresh a profile file to
Permanently save/root/.bash_history don't want to be destroyed or deleted by others
Chattr + a/root/.bash_history Add a permission to this user
If you do not exit normally, use Exit or logout. Then the history command is not preserved.
!! Execute the last command
! n N represents a number. Which history command to execute
! command executes the specified command for the last input
Third, command completion is the alias
tab, if there is only one start, click Auto-Complete. If it is more than two, press two to complete the auto-completion
Yum install-y bash-completion Download a package with auto-completion parameters (need to be active from new boot)
Alisa Aliases
Alisa View all Alisa commands in the system
alisa+ alias = ' command ' create Alisa Alias
unalisa+ aliases Cancel the Alisa alias you created
Four, wildcard characters
* No characters or numbers
? An arbitrary character.
[] inside can write a range. For example, 0-3 or 123, 13 displays 1 and 3 only.
{} is equivalent to 13 square brackets, but the middle is added,
V. Input/Output redirection
> direct the output of the preceding command directly to the following file, overwriting the original contents of the following file
Cat 1.txt > 2.txt
>> append the output of the preceding command to a later file
Cat 1.txt >> 2.txt
2> Error Redirection
2>> Error Append redirect
&> = > and 2>
&>> = >> and 2>>
When you write a shell script, you can separate the errors and correct them to check the script
Linux Learning Notes (23)