Linux command-line editing common shortcut keys (practical, 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 executes the command history list

!! Executes the previous command

!? String? Executes the most recent command with string strings


Ctrl+r then enter several characters, start searching up for the command that contains the character, and continue to press Ctrl+r to search for the previous matching command

Ctrl+s is similar to ctrl+r, just forward retrieval

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!$ executes command ls, and the parameter of one of the above commands is its parameter

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 is clipped (excluding 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 previous 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 join the TAB key

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

CTRL + C Delete entire row

CTRL + (x u) hold CTRL while you press X and u again to undo the action you just made

Ctrl+s suspending the current shell

Ctrl+q to re-enable the suspended shell

[Ctrl] + [Alt] + [Backspace] = kills your current X session. Kill the graphical desktop session and return you to the login screen. If the normal exit step does not work, you can use this method.

[Ctrl] + [Alt] + [Delete] = Shut down and re-boot Red Hat Linux. Close your current session and reboot the OS. 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. According to 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. If 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. If you are working under a 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, if you configure the mouse to simulate the third button, you can click the left and right mouse buttons to perform the paste.

[Tab] = command line auto-complete. You can use this command when using shell hints. Type the first few characters of a command or file name, and then press the [Tab] key, which automatically complements the command or displays all commands that match the characters you type.

[Up] and [down] arrow = show command history. When you use the shell hint, press the [up] or [down] arrows to view the history of the command you typed in the current directory. 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 character is 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 if you are using the shell).

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

# ctrl-z: Pause the program.

# ctrl-s: Stop output to the screen.

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


The default shell, ' Bash ', has historical editing and tab completion.

# Up-arrow: Start history Command search.

# Ctrl-r: Start incremental History Command Search, you can follow the keywords to find out which commands you have used.

# TAB: Complete the input file name 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 application may be slightly advanced a little bit

# !! -Previous command

#!-n-Countdown nth History command

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

# !? String -Latest command with "string"

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

Some other useful Linux command-line key combinations.

Ctrl-alt-del: Suspend or restart the system, these three Linux command line keys under Linux can be easily modified 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.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Linux command-line editing common shortcut keys (practical, 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.