Linux5.2 Shell based on

Source: Internet
Author: User
Tags aliases

Shell Introduction
    • The shell is a command interpreter that provides interaction between the user and the machine
    • Supports specific syntax, such as logical judgment, looping
    • Each user can have their own specific shell
    • CentOS7 default shell is bash
    • and zsh, Ksh and so on.
Command history

The history command is saved in the user's home directory. Bash_history

[[email protected] ~]# cat-n/root/.bash_history     1  init 0     2  dhclient    ...   987  PS aux| grep httpd   988  cat/etc/selinux/config   989  init 0[[email protected] ~]# echo $HISTSIZE     #命令最大保存数量1000 # You can change the maximum number of saves through the environment variable $HISTSIZE, modify it in configuration file/etc/profile, and the source  /etc/profile takes effect #history-c  Can empty the memory of the command history empty # cannot empty records in the command history file [[email protected] ~]# history-c     #刚输入的命令不会马上记录到命令历史文件中, only after exiting the terminal will enter # Modify the History command format to display the time. Added in the configuration file. #HISTTIMEFORMAT = "%y/%m/%d%h:%m:%s" 1. Quick Display the previous command!! 2. Run a command  in the History list!n3. Reverse the first command starting with XXX! XXX4. Save the command file permanently, only add cannot delete        chattr  +a ~/.bash_history
Command completion and aliases

TAB key, complete command and file path.

Auto-complete command parameter completion, need to install Yum install-y bash-completion, and then restart the system.

[Email protected] ~]# systemctl rereboot                 reload-or-restart      reset-failedreenable               Reload-or-try-restart  restartreload                 Rescue

The custom alias is placed in the user's home directory of the ~/.BASHRC, there are some/etc/profile.d/in the script definition, unalias to cancel the custom aliases.

Wildcard characters and redirects
Wildcard characters
  1. LS *.txt* wildcard some arbitrary characters
  2. Ls?. TXT wildcard an arbitrary character
  3. ls [0-4].txt; LS [0-9a-za-z].txt wildcard 0, 1, 2, 3, 4 any of its names. txt all listed
  4. ls {0,2}.txt = ls [0,2].txt does not contain 1.txt
Input and output redirection
  1. Cat 1.txt > 2.txt Front output redirects to the back, which will put the back of the rewrite
  2. Cat 1.txt >> 2.txt front output append to back
  3. LS aaa.txt. 2> a.txt Front Command error output redirect to back
  4. LS aaa.txt 2>> a.txt front Command error output append to back
  5. &> correct error output full redirect to Back, also support append
  6. Command >1.txt 2>2.txt the correct output and errors of a command are saved separately
  7. Wc-l < 1.txt "View 1.txt rows" to the right of the input redirect to the left of the command input, from right to left only left is the command.

Linux5.2 Shell based on

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.