Skip to content

Basic Command Line Shortcuts

2010 December 18
by Joe

The command line is one of the greatest benefits of using Linux or OSX over Windows. One tip that some people do not know is that many familiar emacs shortcuts work on the command line as well. If you are not an emacs user already, here are some of the most basic but useful shortcuts:

CTRL-a Move cursor to beginning of line.
CTRL-e Move cursor to end of line.
ESC-b Move cursor back one word.
ESC-f Move cursor forward one word.
CTRL-k Cuts all characters to the right of your cursor.
CTRL-w Cuts all characters to the left of your cursor.
CTRL-y Paste cut characters at current cursor position.
CTRL-SHIFT-dash Undo cuts, pastes, and typing steps.
CTRL-r Reverse search through your recently executed commands. This one is perhaps the most useful of all the above. Just hit the shortcut, type the first characters of a command you want to run again, and hit enter.

For emacs users these are well baked into muscle memory but even if you hate emacs they are worth learning for when you are working on the command line. Just the small set listed above is enough of a foundation that you can quickly make big changes to your commands with just a few key strokes and generally without having to touch the arrow keys. Combining these basics with a few additional tricks (like using “cd -” to jump back to previous path, sudo !!, etc) can really get your speed up.

Comments are closed.