First, Shell introduction
1, the shell is a command interpreter, providing users and machines to interact, each user can have their own specific shell,
2, CentOS7 default shell for bash, and Zsh,ksh they have the difference in detail,
We can check if the Zsh:yum list |grep is present in the system zsh
What are the features of bash?
Ii. Command History
1, its storage file is:/root/.bash_history
2, when we exit the terminal, it will be stored in the above file.
Its configuration file is:/etc/profile, if you modify the file inside, do not want to quit the terminal to take effect
Run command: Source/etc/profile then use the command to see if it works: Echo $HISTSIZE
3. Change the historyntnt attribute, such as increasing the recording time:
histtimeformat= "%y/%m/%d%h:%m:%s"
1. Use Vim editor/etc/profile to put histtimeformat= "%y/%m/%d%h:%m:%s" variable under variable histsize
Then save the exit,
2, let our command history to save forever, give it a permission to add a: chattr +a/root/.bash_history, and then use lsattr to see it
3 、!! Last command
4,!n (n is a number) For example, you want to run the 66 command:!66
5.!echo it will finally find the command that starts with echo from the history command
Iii. command Completion and aliases
1, Tab hit a complete, knock two (in CENOS6 not support command parameter completion, in CENTOS7 is support Command parameter completion)
2, for example we want to let Systemctl restart Network.service we need to install package: Yum install-y bash-completion, restart:
3, we can make the above command alias: Alias restartnet= "systemctl Restart Network.service"
Four, wildcard characters
1, under Bash, we can use "*" to match multiple characters, with? Matches one character.
V. Input/Output redirection
1. Enter the redirect command:<
2. Output REDIRECT command: >
3. Error REDIRECT command: 2>
4. Append REDIRECT Command:>>
Lesson 22nd Basics of Shell