Working in a command line environment, like a Bash session, can be far more productive that using a graphical user interface. Here’s a collection of shortcuts.

Moving Around The Command Line

ShortcutFunction
Ctrl + aposition the cursor at the start of the line
Ctrl + eposition the cursor at the end of the line
Ctrl + xxalternate the cursor position between start of line and current position
Alt + bmove the cursor backwards a word
Alt + fmove the cursor forewards a word
Ctrl + wcut backwards a word
Ctrl + ucut backwards from the cursor to start of line
Ctrl + kcut forwards from the cursor to end of line
Ctrl + ypaste the contents of the paste buffer
Esc + .paste the last typed argument
Esc + n + Esc + .paste the nth argument from the previous command
Ctrl + _undo
Ctrl + lclear the screen
Ctrl + ccancel the current running command
Ctrl + ddisconnect (exit) the current session

Using Command Line History

ShortcutFunction
historyview command history, with line numbers
!nretrieve the command at line number n
!-nretrieve the nth last command
!stringretrieve the command that starts with string
sudo !!re-execute the last command, but with sudo
^string^newstring^re-execute the last command, replacing string with newstring
Ctrl + rbegin search history mode, type a few characters,
repeat press Ctrl + r for next match
Ctrl + gescape search history mode

Using Arguments From Command Line History

ShortcutFunction
command !$execute command and use the last argument of the previous command
command !*execute command and use all arguments of the previous command
command !:nexecute command and use the nth argument of the previous command
command !m:$execute command and use the last argument of the command at line number m
command !m:*execute command and use the all arguments of of the command at line number m
command !m:nexecute command and use the nth argument of the command at line number m
command !-m:nexecute command and use the nth argument of the the mth last command

Managing Command Line History

Prevent a command from being written to history… precede the command with a space, like this:

1 cat ~/.bashrc

Reliably delete all history, clear the history buffer and prevent history from being re-written on exit:

1cat /dev/null > ~/.bash_history && history -c && exit
ShortcutFunction
cdgo to home directory (same as cd ~)
cd -go to previous working directory
pushd /foo

pushd /bar
push the current directory to the directory stack,
then cd to the /foo directory
push the current directory to the directory stack,
then cd to the /bar directory
popdremove the top directory from the directory stack, then cd to it