8.1 Shell Introduction 8.2 command History 8.3 command completion and alias 8.4 wildcard 8.5 input/output weight

Source: Internet
Author: User
Tags aliases

8.1 Shell Introduction

The shell is the intermediate medium used when the system interacts with the computer hardware, and it is just a tool of the system.
The user directly faces not the computer hardware but the shell, the user instructs the shell, then the shell again to the system kernel, and then the kernel to control the computer hardware to perform various operations.

8.2 Command History

Linux is recorded, and presets can record 1000 historical commands. These commands are saved in the. bash_history file in the user's home directory. One thing you need to know is that commands that run in the current shell are saved to the. bash_history file only when the user exits the current shell normally.

1)!! Two consecutive '! ', indicating the execution of the previous instruction;

[Email protected] ~]# pwd
/root
[[email protected] ~]#!!
Pwd
/root
2)!n here n is a number that represents the nth instruction in the execution of the command history, such as!1002, which represents the 1002th command in the history of the execution of a command;

[Email protected] ~]# history |grep 1002
1002 PWD
1015 History |grep 1002
[Email protected] ~]#!1002
Pwd
/root

History Command if the environment variable has not been changed, the last 1000 commands can be printed by default.

3)! string (string greater than or equal to 1), for example!PW represents the last instruction in the command history to begin with ' PW '.

[Email protected] ~]#!PW
Pwd
/root

8.3 Command Completion and aliases

Command completion is to press the TAB key, which can help you complete a command, can also help you complete a path or a file name. Press the TAB key two times consecutively, and the system will list all the instructions or filenames.

Alias

There has been an introduction to Alias, which is one of the features of bash. We can alias a commonly used and very long instruction by aliases a simple and easy-to-remember instruction. If you don't want to use it, you can also use Unalias to remove the alias feature. Directly hitting alias will see the current system preset alias.

Alias syntax is simple, alias [command alias]=[' specific Command ']
Alias lgx= ' pwd '
Lgx
/root
Unalias LGX
Lgx
Bash:lgx:command not found

8.4 Wildcard Characters

Under Bash, you can use * to match 0 or more characters. Matches one character.

[Email protected] ~]# ls-d test*
Test1.txt test2 test3 test.pl test.txt
[Email protected] ~]# ls-d test?
Test2 test3

8.5 Input and output redirection

Input redirection is used to change the input of the command, and output redirection is used to change the output of the command. Output redirection is more common, and it is often used to enter the results of a command into a file, rather than on the screen. The command to enter the redirect is <, the output redirection command is, and the error redirect 2>, and the Append redirect >>.
Mkdir/tmp/10
Cd/tmp/10
HEAD/ETC/PASSWD > 1.txt
echo "123" >> 1.txt
Cat 1.txt

8.1 Shell Introduction 8.2 command History 8.3 command completion and alias 8.4 wildcard 8.5 input/output weight

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.