Introduction to the Shell
zsh, ksh (yum list |grep zsh to be viewed and then installed accordingly )
Command history
1./root/.bash_history (this file holds the command we've knocked on)
2. History (You can see how many of the commands we've used before.) Maximum of 1000 records can be saved)
Use environment variables to see how many commands are in the Echo $HISTSIZE
3. History-c This command is to clear the memory we have hit the cache command (when we hit the command at the current terminal, it is not immediately saved to the configuration file, but cached in memory), but this command is not deleted /root/.bash_history The contents of this configuration file.
4. When will the command that is hit be saved in the configuration file?
Only we can save to the configuration file when we exit the terminal normally, otherwise it is only temporarily saved in memory (normal exit command: Exit, logout)
5. Environment variable $histsize
Modify the environment variables in the configuration file/etc/profile $HISTSIZE
After you modify the size of the variable, you need to execute source/etc/profile or re-enter the terminal to take effect
6. Check when the hit command is running log down histtimeformat= "%y/%m/%d%h:%m:%s"
(1) define:histtimeformat= "%y/%m/%d%h:%m:%s"
(2) Take a look at the variable: echo $Histtimeformat
But at this point we define the environment variable $histtimeformat is only valid at the current terminal, if the reboot still does not exist
(3) Permanent entry into force, modification of/etc/profile
Vi/etc/profile
Added content:histtimeformat= "%y/%m/%d%h:%m:%s"
7. Command history permanent save does not let others Delete-add hidden condition-A can only append cannot delete
Execute command: chattr +a ~/.bash_history
Conditional +a can only append cannot be deleted
8. Exit/logout for normal exit terminal
When you exit a terminal abnormally, the used command does not log the full
!! Represents the previous command
! n Denotes history nth command
! The string represents a command that has recently used the string from the bottom up and executes
Command completion and aliases
1.tab key not only can not complete the command, also can not complete the file
2. Parameters not fully
(Yum install-y bash-completion)
3.alias aliases:
To set the custom alias:
Alias name = ' The name to be replaced '
Alias restartnet= ' systemctl restart Network.service '
To cancel a custom alias:
Ualias restartnet
where alias is defined
Each user has their own configuration alias file ~/.BASHRC
ls/etc/profile.d/
Wildcard characters
1. *: Indicates 0 or more characters
2.? : represents an arbitrary character
3.ls [0-3].txt
[Range] Any one satisfies the condition, takes only one.
4.ls {1,2,3,a}.txt take a 1 or 2 or 3 or a
input and output redirection
1.> redirect Cat 1.txt>2.txt (input 1.txt content to 2.txt)
2.>> additional cat 1.txt>>2.txt (will not delete the original content, add 1.txt content to 2.txt)
3.ls aaa.txt 2>err to enter the previous error information into a later file
3.ls aaa.txt 2>>err to enter the previous error information into a later file
>+2 = = &>
put [12]txt correct input to A.txt, write aaa.txt error message to B.txt
4.wc-l < 1.txt
Pipe symbol, Job control
Pipe symbol | : Give the output of the preceding command to the input of the following command
Pause task: Ctrl + Z (temporary pause, still to background, back to foreground FG )
Jobs can list the suspended tasks.
FG +id will be able to bring the corresponding suspension to the foreground. FG 2
BG puts the task in the background
Sleep 1000 pause for 1000 seconds
Sleep & plus & can put running tasks directly into the background to perform
Shell Basics: Introduction, historical commands, command incomplete and aliases, wildcard characters, input and input redirection, plumbing and job control