Complete list of shell programming shortcut keys under Linux (daily sorting)

Time:2021-9-26

Sometimes we need to repeat the previous command in bash. Of course, you can use the up arrow key to view the commands that have been run before. But there are some better ways, for example, to master the following shortcut keys.

1) !!: Repeat the previous instruction

2) ! a: Repeat the previous instruction starting with a

3) ! Number: repeat the previous instruction with number recorded in the history table

4) !- Number: repeat the previous number instruction

5) !$: Indicates that the last item in the previous command is obtained

6) Use Ctrl + R to enter the history search mode. Query a past instruction in the history table. After finding the command to be executed repeatedly, press enter to repeat the command parameters (i.e. item 5 in the previous point)

CTRL + P repeats the last command

CTRL + a skip to the first character

CTRL + X is the same as above, but pressing it again will return to the original position

CTRL + B move one character forward without deleting characters

CTRL + H delete previous character

CTRL + U deletes all characters in front of the prompt

CTRL + W ditto

CTRL + D Deletes one character after the prompt or exit or logout

CTRL + e go to end of character

CTRL + F move one character back

CTRL + K deletes all characters after the prompt

CTRL + K cancel

CTRL + R forward to find used commands

CTRL + O Ctrl + y Ctrl + I crtl + M I don’t know how to use these four

< tab > command completion

Ctrl-i is equivalent to pressing the tab < tab > key

Ctrl-w does not delete all characters in front of the cursor. It deletes a word in front of the cursor

Ctrl-p is to recall the previous command < = = > ctrl-n is to recall the next command

Esc-f cursor moves forward one word

Esc-b cursor steps backward one word

Ctrl-m is equivalent to enter

Ctrl-o is equivalent to enter

Ctrl-v enables the next special character to be inserted in the current position. For example, ctrl-v < tab > can insert a < tab > character in the current position, and its ASCII is 9. Otherwise, pressing < tab > generally results in command completion

CTRL – C undoes the editing of the current command line and starts a new line

Ctrl-s temporarily freezes the input of the current shell

Ctrl-q unfreezing

Esc-c capitalizes the first letter of the next word and advances the cursor to a word. If the cursor stays on a letter of the word, such as the O letter in word, the O letter becomes capitalized

Not W

Esc-u capitalizes all letters of the next word and advances the cursor to a word. The same as above. If the cursor is on the O letter, ord becomes capitalized and W remains unchanged

Esc-l is the same as esc-u, but make it all lowercase

After trying all the CTRL keys in Bash, it is summarized as follows (all the keys below are Ctrl keys):

1. U K Y

U deletes the character before the cursor (excluding)

K deletes the characters after the cursor (including)

Y paste the character just deleted

2. D H

D delete the character at the cursor

H deletes a character in front of the cursor

3. A E

A move the cursor to the beginning of the line

E move the cursor to the end of the line

4. F B

F moves the cursor one character to the right

B move the cursor one character to the left

5. N P

N next command

P previous command

6. L

L clear screen

7. R

R searches for previously entered commands

8. T

T replaces the character at the cursor with the character before the cursor

basic skill:

Use the up and down buttons to see the history of commands

Left and right keypad modification

Tab fill in the command name or directory, file name, not unique. Press twice more to display the list

! Ls repeats the last command starting with ‘ls’. If LS – L is followed by LS – LCRT, then! Ls, equivalent to LS – LCRT

ls abc.txt

vi !$

VI on the second line$ Equivalent to VI abc.txt$ Equal to the parameters of the previous command, ‘$’ is the last row, column, etc. according to the context.

CTRL key combination

CTRL + A: move the cursor to the beginning of the line.

CTRL + B: move the cursor one letter to the left

CTRL + C: kill the current process.

CTRL + D: exit the current shell.

CTRL + e: move the cursor to the end of the line.

CTRL + H: delete the character before the cursor, which is the same as the backspace key.

CTRL + K: clear the contents from the cursor to the end of the line.

CTRL + L: clear the screen, equivalent to clear.

CTRL + R: search for previously typed commands. There will be a prompt to search bash history according to the keywords you enter

CTRL + U: clear everything from the front of the cursor to the beginning of the line.

CTRL + W: removes a word in front of the cursor

CTRL + T: swap the first two characters of the cursor position

CTRL + Y: paste or restore the last deletion

CTRL + D: delete the letter of the cursor; Note the difference between backspace and Ctrl + h. These two characters delete the characters in front of the cursor

CTRL + F: cursor moves right

CTRL + Z: turn the current process to run in the background and use the ‘FG’ command to recover. For example, top – D1, then Ctrl + Z, go to the background, then FG, and restore again

ESC combination

ESC + D: delete a word after the cursor

ESC + F: jump one word to the right

ESC + B: jump one word to the left

ESC + T: swap the two words before the cursor position.

The above content is a collection of shell programming shortcut keys under Linux (daily sorting) shared by Xiaobian. I hope it will be helpful to you!

Recommended Today

Supervisor

Supervisor [note] Supervisor – H view supervisor command help Supervisorctl – H view supervisorctl command help Supervisorctl help view the action command of supervisorctl Supervisorctl help any action to view the use of this action 1. Introduction Supervisor is a process control system. Generally speaking, it can monitor your process. If the process exits abnormally, […]