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:
You can delete the last two characters and retype date again. Or oress Ctr-+t to transpose a character.
$ daet [Hit CTRL+t]
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]
$ 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+.]
Use tab key to complete command names or filenames. For example, type the word 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]
ls lsmod lsmod.modutils lspci lsusb lsattr lsmod.Lmodutils lsof
Read the bash man page for more info:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop