Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the commonly used Linux command line shortcuts

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the commonly used Linux command line shortcut keys, the article is very detailed, has a certain reference value, interested friends must read it!

Commonly used

1. Tab

This is the Linux shortcut you can't do without. It will save you a lot of time on the Linux command line.

Just type a command, file name, directory name, or even the beginning of the command option, and press the tab key. It will automatically complete your input or show you all possible results.

If you only remember one shortcut key, this will be the one you must choose.

2. Ctrl + C

These are the keys that should be pressed to interrupt the command or process on the terminal. It will immediately terminate the running program.

If you want to stop using a program that is running in the background, just press this pair of keys.

3. Ctrl + Z

This shortcut sends the running program to the background. Usually, you can do this before using the & option to run the program, but if you forget to use the option to run the program, use this pair of keys.

4. Ctrl + D

This pair of keyboard shortcuts will take you out of the current terminal. If you use SSH connection, it will be closed. If you use a terminal directly, the application will be closed immediately.

Think of it as an "exit" command.

5. Ctrl + L

How do you empty your terminal screen? I guess using the clear command.

You can use Ctrl+L to clear the terminal instead of typing C-L-E-A-R. It's easy, isn't it?

6. Ctrl + A

The shortcut moves the cursor to the beginning of the line.

Suppose you enter a long command or path at the terminal, and you want to go back to the beginning of it, using the arrow keys to move the cursor will take a lot of time. Note that you cannot use the mouse to move the cursor to the beginning of the line.

This is where Ctrl+A saves time.

7. Ctrl + E

This pair of shortcut keys is the opposite of Ctrl+A. Ctrl+A sends the cursor to the beginning of the line, while Ctrl+E moves the cursor to the end of the line.

8. Ctrl + U

Entered the wrong command? Instead of using the Backspace key to discard the current command, use the Ctrl+U shortcut key in the Linux terminal. The shortcut erases everything from the current cursor position to the beginning of the line.

9. Ctrl + K

This pair is a bit like Ctrl+U keyboard shortcuts. The only difference is that it is not the beginning of the line, it erases everything from the current cursor position to the end of the line.

10. Ctrl + W

You just learned about the text erased to the beginning and end of the line. But what if you only need to delete one word? Use the Ctrl+W shortcut key.

Using the Ctrl+W shortcut, you can erase the word in front of the cursor position. If the cursor is over a word itself, it erases all letters from the cursor position to the prefix.

The best way is to use it to move the cursor over a space after the word you want to delete, and then use the Ctrl+W keyboard shortcut.

11. Ctrl + Y

This pastes the text erased using the Ctrl+W,Ctrl+U and Ctrl+K shortcuts. This will come in handy if you delete the wrong text or need to use erased text somewhere.

12. Ctrl + P

You can use this shortcut to view the previous command. You can press the key repeatedly to return to the history command. In many terminals, the PgUp key is used to achieve the same function.

13. Ctrl + N

You can use this shortcut with Ctrl+P. Ctrl+N displays the next command. If you use Ctrl+P to view the previous command, you can use Ctrl+N to navigate back and forth. Many terminals map this shortcut to the PgDn key.

14. Ctrl + R

You can use this shortcut to search for history commands.

Ctrl+ left and right keys: jump between words

Alt-d: delete words to the right, starting with the cursor position. Delete at the end of the line.

Description

Ctrl-k: hold down the Ctrl key first, then press the k key

Alt-k: hold down the Alt key first, then press the k key

M-k: click Esc first, and then press k.

Move the cursor

Ctrl-a: move to the beginning of the line

Ctrl-e: move to the end of the line

Ctrl-b: move one character back (left)

Ctrl-f: move one character backward (right)

Alt-b: move one word back (left)

Alt-f: move one word backward (right)

Ctrl-xx: move between the end of the command line and the cursor

Mmurb: move one word back (left)

Mmurf: move one word back (right)

Editing command

Ctrl-h: deletes the character to the left of the cursor

Ctrl-d: delete the characters to the right of the cursor (Note: when there are no characters on the current command line, the system or terminal will be sold)

Ctrl-w: delete words to the left, starting with the cursor position. Forward line for first deletion

Alt-d: delete words to the right, starting with the cursor position. Delete at the end of the line.

M-d: start with the cursor position and delete the word until the end of the word.

Ctrl-k: starts with the cursor and deletes all characters on the right until the end of the line.

Ctrl-u: start with the cursor and delete all characters on the left until the line begins.

Ctrl-y: paste the previously deleted content behind the cursor.

Ctrl-t: swap the position of the cursor and the first two characters.

Alt +. Use the last argument of the previous command

Ctrl-_: reverts to the previous status. Undo the operation.

Ctrl-a + Ctrl-k or Ctrl-e + Ctrl-u or Ctrl-k + Ctrl-u can delete the entire row.

Bang (!) Command

!!: execute the previous order.

^ Foo ^ bar: replace foo with bar in the previous command and execute it.

! wget: executes the most recent command that starts with wget.

! wget:p: only the most recent commands that start with wget are printed, not executed.

! $: the last parameter of the previous command, compared with Alt -. Same as $_.

! *: all parameters of the previous command

! *: P: print the contents of the previous command that is all parameters, that is,! *.

^ abc: delete the abc from the previous command.

^ Foo ^ bar: replace foo in the previous command with bar

^ Foo ^ bar ^: replace foo in the previous command with bar

!-n: execute the first n commands, execute the previous command:!-1, execute the first five commands in the format:!-5

Find History command

Ctrl-p: displays the last history command of the current command

Ctrl-n: displays the next history command of the current command

Ctrl-r: search history command, enter key executes match command as input displays a match command in history command; ESC key displays on the command line instead of executing match command.

Ctrl-g: exit from the historical search mode (Ctrl-r).

Control command

Ctrl-l: clear the screen, and then redisplay the contents of the line on which the current cursor is located at the top.

Ctrl-o: execute the current command and select the previous command.

Ctrl-s: block screen output

Ctrl-Q: allow screen output

Ctrl-c: terminate the command

Ctrl-z: suspend command

Repeat the operation action

M-number of operations Action: specify the number of operations, repeat the specified operation.

The above is all the contents of the article "what are the commonly used Linux command line shortcuts?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report