Linux command-line editing common shortcut keys (useful, Universal)

Source: Internet
Author: User
Tags clear screen terminates

This article describes the common shortcut keys for Linux command-line editing, which I hope will help you.

Linux Command line edit shortcut keys:

History displays a list of command histories

↑ (ctrl+p) Show previous command

↓ (CTRL + N) Displays the next command

!num the NUM command that runs the command history list

!! Run the previous command

!? String? Run the latest command with string strings


Ctrl+r then enter a number of characters, start searching up the command that includes the character, continue to press CTRL+R, search for the previous matching command

Ctrl+s is similar to Ctrl+r and is just a forward search

alt+< History list First item

alt+> History list Last item

CTRL+F cursor moves forward one character, equivalent to

CTRL+B cursor moves backward one character, quite with <-

ALT+F cursor moves forward one word

ALT+B cursor moves backward one word

LS!$ Run command ls, and the parameters of the above command are the number of its parameters

CTRL + A moves to the beginning of the current line

Ctrl+e move to the end of the current line

Esc+b move to the beginning of the current word

Esc+f move to the end of the current word

Ctrl+l Clear Screen

Ctrl+u all characters before the cursor in the command line (not including itself)

Ctrl+k all characters (including itself) after the cursor in the command line is clipped

Ctrl+d Delete the character at the cursor location

Ctrl+h Delete the previous character where the cursor is located

Ctrl+y Paste the character you just deleted

Ctrl+w A word that precedes the clipping cursor (with spaces, punctuation, and so on as separators)

Alt+d the words after the clipping cursor

Esc+w Delete the character that precedes the cursor to the end of its word (separated by spaces, punctuation, and so on)

Ctrl+t reverses the position of the character where the cursor is located, and moves the cursor to the next character

Alt+t Exchange Current and past word position

Alt+u convert the current word to uppercase

Alt+l convert the current word to lowercase

Alt+c to capitalize the current vocabulary into the first character

CTRL + V inserts special characters, such as ctrl+v+tab add Tab key

Esc+t reverses the position of the cursor and its adjacent words

CTRL + C Delete entire row

CTRL + (x u) hold CTRL the same time and then press X and U again to undo the action you just made

Ctrl+s suspending the current shell

Ctrl+q once again enable the suspended shell

[Ctrl] + [Alt] + [Backspace] = kills your current X session. Kill the graphical desktop session and return you to the login screen.

Assuming the normal exit step does not work, you can use this method.

[Ctrl] + [Alt] + [Delete] = shut down and boot Red Hat Linuxagain.

Close your current session and boot the OS again. Use this method only if the normal shutdown step does not work.

[Ctrl] + [Alt] + [Fn] = Toggle screen.

[Ctrl] + [ALT] + one of the function keys will display a new screen. Depending on the default settings, from [F1] to [F6] is the shell prompt screen, [F7] is a graphical screen.

[Alt] + [Tab] = switch tasks in a graphical desktop environment. Assuming you have more than one application open at the same time, you can use [Alt] + [TAB] to switch between open tasks and applications.

[Ctrl] + [A] = move the cursor to the beginning of the line.

It can be used in most text editors and in the URL fields of Mozilla.

[Ctrl] + [d] = Log off (and close) from the shell prompt.

With this shortcut, you don't have to type exit or logout.

[Ctrl] + [E] = move the cursor to the end of the line. It can be used in most text editors and Mozilla's URL fields.

[Ctrl] + [l] = clear the terminal. This shortcut works the same as typing clear at the command line.

[Ctrl] + = Clears the current line. Let's say you work under the terminal. Use this shortcut to clear the characters from the cursor to the beginning of the line.


[middle mouse button] = paste the highlighted text.

Use the left mouse button to highlight the text.

Point the cursor to the place where you want to paste the text. Click the middle mouse button to paste it. In a two-button mouse system. Suppose you configure the mouse to simulate the third key. You can click the left and right mouse buttons at the same time to run the paste.

[Tab] = command line self-complement. You can use this command when using shell hints. Type the first few characters of the command or file name. Then press the [Tab] key. It will take its own initiative to complete commands or display all commands that match the characters you type.

[Up] and [down] arrow = show command history. When you use the shell tip, press the [up] or down arrows to view the history of the command you typed in the current folder. When you see the command you want to use, press the [Enter] key.

Clear = Clears the shell prompt screen. Typing it at the command line clears all the data displayed in this shell prompt screen.

Exit = Logoff.

Type it in the shell prompt to log off the current user or root user account.

History = Show Command Histories. Type it in the shell prompt to display the top 1000 numbered commands that you typed. To display a shorter command history, type a number in the empty space after you have entered the historical F. For example: History 20.


reset = Refresh the shell prompt screen.

If the characters are not clear or garbled, typing this command at the shell prompt refreshes the screen.

# Ctrl-u: Erases the previous section of a row of cursors.

# ctrl-h: Erases one character before the cursor.

# ctrl-d: Terminates the input. (Exit the shell, assuming you're using the shell.)

# ctrl-c: Terminates the program that is currently executing.

# ctrl-z: Pause the program.

# ctrl-s: Stop output to the screen.

# Ctrl-q: Again activates the output to the screen.


The default shell, ' bash '. There are historical editing and tab completion functions.

# Up-arrow: Start history Command search.

# Ctrl-r: Start the Incremental history command search and be able to follow keyword to find out which commands you have used.

# TAB: Complete the file name input to the command line.

# ctrl-v Tab: Enter tab instead of extension command line.

# Ctrl + P-Previous command

# Ctrl + N-Next command

# Ctrl-u: Erases the previous section of a row of cursors.

# Ctrl + Y-paste the previous Ctrl+u class command to delete the characters, is the paste is not undone Ah!

The following applications may be slightly advanced a little bit

# !! -Previous command

#!-n-Countdown nth History command

#!-n:p-Print the previous command (not running)

# !?

String -Latest command with "string"

#!-n:gs/str1/str2/-Replaces the str1 of the last nth command with STR2 and runs (replaces the first only if no G is added)

Some other useful Linux command-line key combinations.

Ctrl-alt-del: Suspend or start the system again, these three Linux command line keys under Linux can easily change to shutdown operation, which is very convenient for single-user friends


# Ctrl + L-Clear screen

# Ctrl + A-cursor moves to the beginning of the line

# Ctrl + E-the cursor moves to the end of the line

# Ctrl + W-clear the cursor before a word

# Ctrl + K-Clears the character of the cursor to the end of the line

# Ctrl + T-swap the first two characters of the cursor

# CTRL + V-input control word such as CTRL + V. will enter ^M

# Ctrl + F-Move the cursor back one character

# Ctrl + B-cursor moves forward one character

# Ctrl + H-delete a character before the cursor

# N++F-Move the cursor back n words, n is 1 can be omitted

# N++B-the cursor moves forward n words, n is 1 can be omitted

# Left-click-and-drag Mouse: Select and copy to Clipboard.

# Click middle mouse button: Paste using the contents of the Clipboard.

# Meta-key (Emacs terminology) is traditionally used in Left-alt-key


These are the methods for editing shortcut keys on the Linux command line.

Linux command-line editing common shortcut keys (useful, Universal)

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.