I recently spent sometime reading two Linux command line books. The first is William Shotts’ The Linux Command Line (2e), and the second one is Learning the Bash Shell by Cameron Newbam and Bill Rosenblatt. Both books are good. The first book is written in a tutorial style and easy to understand. The second one is on Bash shell only and is more thorough.
The Learning the Bash Shell book is in its third edition, and the book was published in April 2005. The first edition was published in 1995, so it is an old book. The third edition covers Bash 3.0. Bash 5.0 has already been released. However, most contents in the book still apply to current release.
Chapter 2 of the book describes that Bash has two editing mode: emacs and vi.
The default is emacs mode. When you open a Terminal window (Ctrl + Alt + T) in
Ubuntu, the command line is in emacs editing mode. You can change it to vi mode
set -o vi and change it back by
set -o emacs. The emacs mode
is adequate for most situations. The mode has some useful shortcuts (listed
below) in addition to common ones like Tab, Arrow Up, Arrow Down.
Ctrl + a: Move cursor to the beginning of the line
Ctrl + e: Move cursor to the end
Ctrl + r: Search command history (Reverse incremental search)
Ctrl + j: Work with
Ctrl + r, copy command to command line
Ctrl + k: Delete from cursor to the end of the line
Ctrl + u: Delete from the beginning of the line to cursor
Ctrl + l: Clear the screen
Ctrl + t: Transpose two character
A reddit post “do you use bash vi mode” has some interesting discussion on whether to use vi mode. I personally think emacs mode with the above shortcuts is good enough.