Summary of the Linux Learning Bash (ongoing ...)

Source: Internet
Author: User
Tags aliases parent directory

Linux Summary bash features

  1. Command history:
    1. Use command: History
    2. Environment variables:
      1. Histsize: The number of bars recorded in the command history buffer, which defaults to 1000;
      2. Histfile: Record the current logged-in user logout the history command to store files;
      3. Histfilesize: Command history file records the number of history, the default is 1000;
    3. Operation Command History:
      1. History d offset deletes the command histories for the specified line;
      2. History c empties the command in the historical buffer of the command;
      3. History # shows the most recent # commands from the past;
      4. History a manually appends the commands in the current session buffer to the historical file;
    4. To invoke a command in history:
      1. !#: Execute the # command repeatedly;
      2. !: Repeat the previous one (last command;)
      3. !string: Repeats the last command that begins with the specified string;
      4. Call the last parameter of the previous command:
        1. !$
        2. ESC,.

    1. Control how the Command history is recorded:

      Environment variable: Histcontrol

      Three values:

      Ignoredups: Ignoring duplicate commands; the so-called repetition must be continuous and identical, including options and parameters;

      Ignorespace: Ignores all commands that begin with whitespace, not records;

      Ignoreboth: Ignore the above two items, both ignore the duplicate command, also ignore the beginning of the blank command;

How to modify environment variables:

Export variable name = "VALUE"

Or: Varname= "VALUE" Export VARNAME

    1. Command completion:

      Internal command: Directly through the shell completion;

      External command: Bash searches for a file named for a given command from left to right, based on the path defined by the PATH environment variable, and is the command to be executed the first time it is found;

      Note: After the first search through path to the command, it will be stored in the hash cache, the next use no longer search path, from the hash to find;

      650) this.width=650; "src=" "/>

      TAB completion:

      If the user-given character is in the command search path and only one command matches it, the TAB key is directly complete;

      If the character entered by the user has more than one command in the command search path, the TAB key can be used to list the commands again;

    1. Path Completion:

Begins with a string entered by the user as a path and searches the parent directory of its specified path for the file name beginning with the specified string;

If the only, then direct completion;

Otherwise, tab again to list all eligible paths and files;

    1. Command line expansion:

1) ~: Expand to the user's home directory;

2) ~username: Expand the home directory for the specified user;

    1. {}: Can host a comma-delimited list and expand it to multiple paths;

650) this.width=650; "src=" "/>

    1. Execution result status of the command:

      Success or failure;

      Bash uses a special variable $? Save the execution status result of the most recent command;

      Value: 0: Success;

      1-255: Failure, 1,127,255 for system retention;

      Program execution has two types of results:

      The return value of the program, the output of the execution of the program itself;

      The execution status result of the program;

650) this.width=650; "src=" "/>

    1. Command Aliases (alias)
      1. Implemented by the alias command:
        1. Alias displays all the available command aliases for the current shell process;
        2. Define alias: Alias Name= ' VALUE ' defines the alias name, which executes equivalent to executing the command value,value can contain commands, options, parameters;
        3. To define a command alias by modifying the configuration file:

        Current User: ~/.BASHRC

        Global Users:/ETC/BASHRC

The bash process re-reads the configuration file:


. /path/to/config_file

Revoke alias: Unalias

Unalias [-A] name [name ...]

Note: For commands that define aliases, use the original command to use the \command

650) this.width=650; "src=" "/>

    1. Glob (globing)

Used in bash to implement file name "wildcard"

Wildcard characters: *,? ,[]

    1. * Arbitrarily from any character of length;


      650) this.width=650; "src=" "/>

    2. ? any single character;


      650) this.width=650; "src=" "/>

    3. [] matches any single character within the specified range;

      [0-9] [A-z] is case insensitive

      [admin] can be in the form of an interval, or it can be discrete;

4) [^] matches any character outside the specified range;

[^0-9] Any character of a single non-digit;

Dedicated Character Set:

[:d igit:] Any single number equivalent to [0-9]

[: Lower:] Any single lowercase letter,

[: Upper:] any single capital letter;

[: Alpha:] Any single case of uppercase and lowercase letters;

[: Alnum:] any number or letter;

[: space:] any white space character;

[:p UNCT:] any single special character;

Note: When using [] to reference a dedicated character set, the outer layer also needs to be nested []. For example:

# ls-d/etc/l*[[:d igit:]]*[[:lower:]]

    1. Bash shortcut keys:

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: 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.