Issue
Consider:
ssh -i "key.pem" [email protected]
Is there a quick way to jump to the beginning of "root" in such a Bash command in the terminal, without iterating over every word/character?
Solution
Yes. Bring up the last command using up arrow. These shortcuts will help:
- Ctrl + E - go to the end of the line
- Ctrl + A - go to the start of the line
- Alt + left - go back one word
- Alt + right - go right one word
- Ctrl + W - delete the last word
To search the command line and the command line history, use:
- Ctrl + R and then type the search string, e.g. "roo" to search backwards for "root@...". In the example you have given, however, it will be easier just to jump forward or back by words.
- Ctrl + S search forwards (rarely useful). (If forward searching doesn't appear to work, try this other Stack Overflow answer.)
See also this page and google "Bash command line editing" for more tricks.
Answered By - Alex Harvey Answer Checked By - Mary Flores (WPSolving Volunteer)