Linux Command Line Shortcuts & Keyboard Shortcuts

Command Line TerminalThe downside to using the command line is all the typing that it involves. Even if you enjoy typing, it can get tedious after awhile.

That is why I have so much fun learning about all of the shortcuts that can be used in the command line, to cut down on the amount of time spent typing.

Not only are there tricks available that can do half of the work for you, but there are also keyboard shortcuts that can help you to navigate the command line in half the time.

Command Line Shortcuts

The tilde ~ is an abbreviation indicating the home directory of the current user. Examples: ls ~ or cd ~/Downloads

A dash – indicates the last directory you were in; it can be used as a shortcut/alternative to typing in the previous directory path. Example: cd -

A single dot . stands for the current directory. It can be used in place of typing out the full directory path. Example: cp /tmp/file.txt .

Double dots .. stand for the parent directory. They can be used in place of typing out the full directory path. Example: cd ../

Appending an ampersand & to a command will allow it to run in the background, without tying up the command line. This is very good, in the case of running a program, etc. because they are less likely to be terminated prematurely. This is very bad for many other commands, if you need to know if/when they are finished, and any other pertinent details. Example: kate&

Use !$ as an argument to recall the last argument from the last command run. For example, running touch NewFile.txt, followed by mv !$ /tmp will create a new file and then move it to the tmp directory.

Use the Esc + . shortcut to recall the last argument from the last command run, and edit it before the current command is run.

Use double ampersands && to separate two commands; the second command will only run if the first one completes successfully. Example: mkdir temporary && cd temporary

Using the -v option (meaning “verbose”) with many commands will display the command’s progress in real time, as opposed to them running without status reports.

Navigational Keyboard Shortcuts

Ctrl + B – Move Cursor to the Left (One Character)

Ctrl + F – Move Cursor to the Right (One Character)

Alt + B – Move Cursor to the Left (One Word)

Alt + F – Move Cursor to the Right (One Word)

Ctrl + A or Home – Move Cursor to Beginning of Line

Ctrl + E or End – Move Cursor to End of Line

Ctrl + T – Swap Closest Two Characters Left of the Cursor

Esc + T – Swap Closest Two Words Left of the Cursor

Esc + B – Move to Beginning of the Previous/Current Word

Esc + F – Move to End of the Previous/Current Word

Alt + C – Capitalize Letter By Cursor, Move to End of Word

Ctrl + Left and Ctrl + Right – Jump Between Arguments

Copy/Paste Keyboard Shortcuts

Shift + Insert – Paste From Clipboard

Ctrl + Shift + C – Copy To Clipboard

Ctrl + Shift + V – Paste From Clipboard

Middle Mouse Button – Paste From Clipboard (or Paste Selected Text)

Ctrl + U – Cut Current Line From Beginning to Cursor

Ctrl + K – Cut Current Line From Cursor to End

Alt + D – Cut the Word After the Cursor

Ctrl + W – Cut the Word Before the Cursor

Ctrl + Y – Paste the Cut Text

Alt + Y – Paste the Second-to-Last Cut Text

History Keyboard Shortcuts

Up Arrow or Ctrl + P – View Command History, Move to Previous Line

Down Arrow or Ctrl + N – View Command History, Move to Next Line

Backspace, Ctrl + H or Ctrl + C – Clear Command Prompt

Ctrl + R – Search For Previous Command From History

Ctrl + J – End Search (Selects Current Search Result)

Ctrl + G – Abort Search (Restores Original Line)

Other Keyboard Shortcuts

Ctrl + L – Clears Terminal Screen

Alt + R – Restores Changes Made to Current Line

Esc + . – Recalls Last Argument from Last Command

Ctrl + C – Kill/Cancel Current Command/Operation, Start With Fresh Prompt

Ctrl + Z – Pause Current Command/Operation (Resume In Foreground With fg) (Resume In Background With bg)

Ctrl + Alt + F1, F2, F3, … – Switches to Virtual Console (Full Screen Command Line)

Alt + F1 – Switches Back to GUI (From Virtual Console)

Ctrl + D – Exit Terminal

Ctrl + Alt + Del – Reboot Computer


How many of these shortcuts did you know already? Am I missing some? Let us know in the comments!

Leave a Reply

You have to agree to the comment policy.