Linux Command Line editing common shortcut keys (practical, General), linux Command Line

Source: Internet
Author: User

Linux Command Line editing common shortcut keys (practical, General), linux Command Line

This article describes common shortcut keys for Linux Command Line editing.

Linux Command Line editing shortcut:

History display command history list

← (Ctrl + p) display the previous command

Hide (Ctrl + n) display the next command

! Num: The num command in the History list.

!! Run the previous command

!? String? Execute the latest command containing string strings


Ctrl + r enter several characters and start to search for the command containing the character up. Continue to press Ctrl + r to search for the previous matched command.

Ctrl + s is similar to Ctrl + r, only forward Retrieval

Alt + <first item in the History List

Alt +> last item in the History List

Ctrl + f move the cursor one character forward, equivalent to->

Ctrl + B move the cursor one character backward, equivalent to <-

Alt + f move a word forward with the cursor

Alt + B Move a word behind the cursor

Ls! $ Execute the ls command and set the parameters of the preceding command

Ctrl + a move to the beginning of the current row

Ctrl + e move to the end of the current row

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 cut all the characters before the cursor in the command line (excluding itself)

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

Ctrl + d Delete the character at the cursor

Ctrl + h Delete the character before the cursor

Ctrl + y paste the deleted character

Ctrl + w cut the word before the cursor is located (separated by space, punctuation, etc)

Alt + d cut words after the cursor

Esc + w Delete the characters before the cursor is located to the end of the word (separator: space, punctuation, etc)

Ctrl + t flip the cursor and its previous character location, and move the cursor to the next character

Alt + t exchange the current and previous word locations

Alt + u converts the current word to uppercase

Alt + l convert the current word to lowercase

Alt + c converts the current word into uppercase letters

Ctrl + v Insert special characters, such as Ctrl + v + Tab to add the Tab character key

Esc + t place the cursor and its adjacent words upside down

Ctrl + c Delete the entire row

Ctrl + (x u) press Ctrl and then press x and u to cancel the previous operation.

Ctrl + s suspend the Current shell

Ctrl + q restart the suspended shell

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

[Ctrl] + [Alt] + [Delete] = shut down and reboot Red Hat Linux. Close your current session and reboot the OS. This method is used only when the normal shutdown step does not work.

[Ctrl] + [Alt] + [Fn] = switch the screen. [Ctrl] + [Alt] + one of the function keys will display a new screen. According to the default settings, from [F1] to [F6] is a shell prompt screen, and [F7] is a graphical screen.

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

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

[Ctrl] + [d] = log out (and close) from the shell prompt ). You do not need to enter exit or logout.

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

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

[Ctrl] + = clear the current row. If you work in a terminal, use this shortcut to clear the characters from the cursor to the beginning of the line.


[Intermediate mouse key] = 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 key to paste it. In the two-Key mouse system, if you configure the mouse to simulate the third key, you can click both the left and right keys of the mouse to paste them.

[Tab] = command line auto-completion. Use this command when prompted by shell. Type the first few characters of the command or file name, and press the [Tab] key. It will automatically complete the command or display all commands that match the characters you typed.

[Up] and [Down] arrows = show command history. When you use shell prompts, press the [Up] or [Down] arrow to view the command history you typed in the current directory. When you see the command you want to use, press the [Enter] key.

Clear = clear the shell prompt screen. Type it in the command line to clear all the data displayed on the shell prompt screen.

Exit = logout. In the shell prompt, type it to log out of the current user or root user account.

History = displays the command history. In the shell prompt, type it to display the first 1000 commands you have typed. To display a short command history, enter history f and enter a number. For example, history 20.


Reset = Refresh the shell prompt screen. If the characters are not clear or garbled, type this command at the shell prompt to refresh the screen.

# Ctrl-U: erase the part before the cursor of a row.

# Ctrl-H: erase a character before the cursor.

# Ctrl-D: Terminate the input. (Exit shell, if you are using shell ).

# Ctrl-C: Terminate the currently running program.

# Ctrl-Z: Pause the program.

# Ctrl-S: Stop output to the screen.

# Ctrl-Q: reactivate and output to the screen.


The default shell, 'bash', has the history editing and tab completion functions.

# Up-arrow: Start history command search.

# Ctrl-R: Start the incremental history command search. You can check which commands you have used based on the keywords.

# TAB: Enter the complete file name in the command line.

# Ctrl-v tab: Enter the TAB instead of extending the command line.

# Ctrl + P-previous command

# Ctrl + N-next command

# Ctrl-U: erase the part before the cursor of a row.

# Ctrl + Y-paste the character deleted by the previous Ctrl + U command. paste it, not undo it!

The following applications may be slightly more advanced.

#!! -Previous command

#! -N-last N historical commands

#! -N: p-print the previous command (not run)

#!? String? -The latest command containing "string"

#! -N: gs/str1/str2/-replace str1 of the nth command with str2 and execute the command (if g is not added, replace only the first command)

Other useful Linux Command Line key combinations.

Ctrl-Alt-Del: suspends or restarts the system. These three Linux Command Line buttons can be easily changed to shutdown operations in Linux, this is very convenient for single-user friends.


# Ctrl + l-clear screen

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

# Ctrl + E-move the cursor to the end of the row

# Ctrl + W-Clear the word before the cursor

# Ctrl + K-Clear the characters from the cursor to the end of the line

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

# Ctrl + V-enter the control character, for example, Ctrl + v. ^ M is entered.

# Ctrl + F-move a character behind the cursor

# Ctrl + B-move the cursor one character forward

# Ctrl + H-delete the character before the cursor

# N ++ F-move N words behind the cursor. If N is 1, it can be omitted.

# N + + B-move the cursor forward N words. If N is 1, it can be omitted.

# Left-click-and-drag mouse: select and copy to the clipboard.

# Click middle mouse button: paste the content of the clipboard.

# Meta-key (Emacs terminology) traditionally uses Left-Alt-key


The preceding method is used to edit the shortcut key of a Linux Command Line.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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.