Bash Command Line Keyboard Shortcuts For Linux / Unix Users

Working at the shell prompt is an essential task for any Linux system administration. However many newcomers find it difficult to work at the bash prompt. Here are some tricks to speed up your work.

Essential bash keyboard shortcuts

CTRL-l : Clear the screen.

CTRL-r : To search for a command in command history. For example yesterday or few hourse back you typed ‘a very very long command’ and you need the same command again. hit CTRL+r and type first few letters of command.

CTRL-c : Cancel command.

CTRL-z : Suspend command.

CTRL-t : Transpose characters. For example you misspelled command date:
$ daet
You can delete the last two characters and retype date again. Or oress Ctr-+t to transpose a character.
$ daet [Hit CTRL+t]
Sample outputs:

$ date

ALT+t OR ESC+t: Transpose words. For example you typed the following command:
$ filename rm
To correct the command as rm filenamejust press Ctrl-t
$ filename rm [ALT+T]
Sample outputs:
$ rm filename

CTRL-u : Deletes entire line.

CTRL-k : Deletes to end of line from current cursor position.

HOME OR CTRL-a : Moves cursor to beginning of line.

END OR CTRL-e : Moves cursor to end of line.

Recall last argument from the previous command and save time

ALT+. – Hold down ALT key and press period/dot. For example, you typed the mkdir command as follows:
$ mkdir -p /tmp/demo/software/qtapp

Next, you need change directory to /tmp/demo/software/qtapp, type cd and press ALT-.:
$ cd [PRESS alt+.]

Command completion

Use tab key to complete command names or filenames. For example, type the word mo:
$ mo
Hit the TAB key to complete the word
$ mo [TAB]

List the possible completions

BASH also supports the possible completions of commands or text (file). For example you would like to list all the possible command starts with the word ls:
$ ls [ESC]
Sample outputs:

ls lsmod lsmod.modutils lspci lsusb
lsattr lsmod.Lmodutils lsof

See also

Read the bash man page for more info:

man bash
🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • Philippe Petrinko May 10, 2010 @ 22:08

    A thing to amend:
    “CTRL-U : Deletes entire line”

    No, CTRL-U Deletes from current cursor position to beginning of line (the opposite of CTRL-K)

    • Eddie Aug 2, 2014 @ 20:43

      CTRL-U, does not delete anything! It cuts from the beginning of the line into your bash ‘clip board’.

      CTRL-Y then pastes it

  • Anonymous Aug 31, 2005 @ 13:39

    Hmm that is cool, you can also read more shortcut keys in bash man page.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.