Knowing these time-saving shortcuts can be a great boon for those using the shell often. Most of these commands are used for quick navigation or editing of the current command line.
1. To Move Around :
To move to the beginning of the current line,
Ctrl + A
To move to the end of the current line,
Ctrl + E
To move the cursor forward one word on the current line,
Alt + F
To move the cursor backwards one word on the current line,
Alt + B
2. To Manipulate Text :
To clear the characters on the line before the current cursor position,
Ctrl + U
To clear the characters on the line after the current cursor position,
Ctrl + K
To delete the word in front of the cursor,
Ctrl + W
To delete the word after the cursor,
Alt + D
You can also search history quickly using,
Ctrl + R
you’ll be given a prompt:
(reverse-i-search)`':
Type what you’d like to search for, such as ssh, and you’ll get the first matching entry in the history. Continue pressing [Ctrl][R] to search further back in the history for all entries that contain ssh. When you find the one you want, press [Enter]. If you need to modify a command that you find, use the right arrow to break out of the search and make the changes you need.
To make the current word after the cursor uppercase,
Alt + U
To make the current word after the cursor lowercase,
Alt + L
Note: The cursor position here is important, if the cursor is midway in the word, only the part of the word after the cursor will have the case changed
To capitalize a word,
Alt + C
Keyboard shortcuts save steps and knowing these few shortcuts when working on the command-line can save a lot of time and typing.