This happens to me all the time: I type a long command line and forget to specify some options. For example:

$ tcpdump host foo.com and port 8080

Hmm, I should be seeing some output. Ah! Forgot to listen on a different interface.

At this point I'd hit the up-arrow to bring back the previous command, then either scroll back to the first argument or press C-a to jump to the start of the command and scroll forward to the first argument.

Is there a quicker way to jump to the first argument so I can insert the -i eth1 option?


I believe the closest shortcut without key rebindings is CTRL-A, ALT-F (ESC-F in Mac).


Command line editing can be done using either emacs style commands or vi style commands. The default is emacs (See Jin's answer).

If you are more used to vi than emacs you can switch this editing mode in your ~/.bashrc file by adding set -o vi Then you can use any vi commands you are familiar with

Esc, 0, e, a (start of line, end of word, append)
Alt+0, w, i (start of line, next word, insert)
Alt+5, B, i (go back 5 words, insert)
Alt+F, h, i (find "h" going backwards, insert).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.