Linux command-line important shortcut keys

Source: Internet
Author: User
Tags touch command

To learn the command line, you need to master a few very useful and necessary tips

1. [Tab]

Using the Tab key to complete the command, the greatest benefit of this technique is that when you forget the full name of a command, you can simply enter a part of its beginning and press the Tab key to get a hint or help. Of course, not only complete the command, complete the directory, complete the command parameters are no problem

2. [Ctrl + C]

Think you have not encountered this situation, when you inadvertently entered a command in the Linux command, or the wrong use of a command, resulting in the terminal you can not expect, for example, only the cursor in the blink can not continue to enter the command, or constantly in the output of a lot of you do not want results. What should you do if you want to stop immediately and return to your controllable state? At this point you can use Ctrl+c the key to forcibly terminate the current program (you can rest assured that it does not cause the terminal to exit)

3. Learn to use historical input commands

Very simple, you can use the arrow keys on the keyboard to restore the commands you have entered before, you know, it's really cool.

4. Learn to use wildcard characters

A wildcard is a special statement that has an asterisk (*) and a question mark (?), which is used to make a fuzzy match to a string (such as a file name, parameter name). When you look for a folder, you can use it instead of one or more real characters, and you often use wildcards instead of one or more real characters when you don't know the real characters or are too lazy to enter the full name.

The wildcard character entered in the terminal is handled by the shell, not by the command statement involved, it will only appear in the command "parameter value" (it does not have in the command name, the command does not remember, then use the Tab completion). When the shell encounters a wildcard character in the parameter value, the shell treats it as a path or file name to search for a possible match on disk: If a matching match exists, the substitution (path extension) is performed, otherwise the wildcard character is passed as a normal to "command" and then processed by the command. In short, a wildcard is actually a kind of path extension that the shell implements. After the wildcard is processed, the shell completes the reorganization of the command before continuing with the reorganized command until the command is executed.

Say so much, feel it.

Create 2 files with the Touch command first, with a txt suffix

$ touch adsfasd.txt wergjlkas.txt

A strange file name? I did it on purpose, meaning you can enter whatever file name you want. Then the accident happened, after a long time, you have forgotten the file name of the two files, now you want to find the two text files in your heap of other files, then you can use the wildcard character

Oh, there's nothing great about it, not to panic, and even worse, if you want to create some of these files in windows at once what do you do,"Love_1_linux.txt, Love_2_linux.txt,... love_10_ Linux.txt ", do not know how to do it. But it's a very important thing for Linux.

$ touch love_{1..10}_linux.txt

5. Learn to get help from the command line

Imagine if you are a petite and weak sister, when you meet the physical life, you will do, haha, do not want to be sure to find man (men) to help. Yes, we are in the Linux environment, if you encounter difficulties, whether men and women, whether delicate, you can find man (men) to help, but to understand that it is not real man, just Manual page the abbreviation.

Manual pages is a common form of online software documentation on UNIX or UNIX-like operating systems. The content includes computer programs (including libraries and system calls), formal standards and conventions, and even abstract concepts. The user can invoke the man page by executing the man command.

You can use the following methods to get a detailed description of a command and how to use it

$ man <command_name>

For example, if you want to see how the man command itself is used, you can enter

man man

Normally, the contents of the Man Handbook are in English, which requires you to have a certain foundation in English. The man manual is a lot of content, involving all aspects of the Linux use process, in order to facilitate the search, is to do a fascicle (sub-section) processing, in the Unix, BSD, OS x and Linux, the manual is usually divided into 8 sections, arranged as follows:

Section Description
1 General Command
2 System calls
3 Library functions, covering the C standard function library
4 Special files (usually devices in/dev) and drivers
5 File formats and conventions
6 Games and Screensavers
7 Miscellaneous
8 System administration Commands and Daemons

To view the contents of the corresponding section, add a number to the corresponding section after the man, as follows:

3 printf

All hand albums follow a common layout, which is optimized for simple ASCII text display, which may not have any form of highlighting or font control in this case. The following sections are generally included:

Name (title)

The name of the command or function followed by an introduction to the line.

Synopsis (Summary)

For the command, formally describe how it runs, and what command line parameters are required. For a function, describe the parameters required for the function, and which header file contains the definition of the function.

DESCRIPTION (note)

A textual description of the function of the command or function.

EXAMPLES (example)

Some examples are commonly used.

See ALSO (cf.)

A list of related commands or functions.

There may also be other parts of the content, but these parts are not standardized across manual pages. Common examples include options (option), exit status (Exit State), Environment (Environment), BUGS (Program Vulnerability), files (file), AUTHOR (author), REPORTING BUGS (known vulnerability), History and Copyright (copyrights).

There are usually a lot of things in the Man Handbook, you may not be easy to find the results you want, but fortunately you can use the search in man, /<你要搜索的关键字> and after finding you can use the key to switch to the next keyword where the n last keyword is located shift+n . Use Space (SPACEBAR) to page, Enter (enter) scroll down one line, or use j , k (Vim Editor's move key) to scroll backward one line forward. Press the h key to show use Help (because man uses less as a reader, which is less the tool's Help), press q exit

For more detailed help, you can also use info commands, but man it is often enough to use them. If you know the role of a command, just want to quickly see some of its specific parameters of the role, then you can use --help parameters, most of the commands will have this parameter, such as

$ ls --help

Shell Common wildcard characters:

character meaning
* Match 0 or more characters
? Match any one character
[list] Match any single character in the list
[!list] Matches a character other than any single character in the list
[c1-c2] Match any single word in c1-c2 such as: [0-9] [A-z]
{string1,string2,...} Match sring1 or string2 (or more) one string
{c2..c2} Match all characters in c1-c2 such as {1..10}


Some other common shortcut keys

Key function
Ctrl+d Keyboard input end or exit terminal
Ctrl+s Tentative current program, pause and press any key to resume operation
Ctrl+z Put the current program in the background to run, revert to the foreground commandfg
Ctrl+a Move the cursor to the input wardrobe equivalent to the Home key
Ctrl+e Moves the cursor to the end of the input line, equivalent to the End key
Ctrl+k Remove from cursor position to end of line
Alt+Backspace Delete a word forward
Shift+PgUp Scroll the terminal display up
Shift+PgDn Scroll down the terminal display


Linux command-line important 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: 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.