Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Depending on his type of usage, an Ubuntu user may spend a lot of time in front of a terminal. Knowing some keyboard shortcuts can make you save a lot of time (ex: copy/paste text, move between the prompt text, etc).
So which bash tips/shortcuts do you guys know?
Shift+PageUp/Shift+PageDown - Scrolling the terminal output. This is very handy when using an tty: in Gnome Terminal works the same way as dragging the scroolbar.
Ctrl+s - Pauses the output: the command keeps running, only their output stops.
Ctrl+q - Resume the output: when output is paused, this will make the command show their output again.
Ctrl+l - Clear terminal output.
Ctrl+u - Deletes all the text currently typed in the prompt.
Ctrl+k - Deletes all the text from the right of the cursor
Ctrl+w - Deletes a word, from right to left.
Ctrl+a - Move to the beginning of the text.
Ctrl+e - Move to the end of the typed text.
Ctrl+Left/Right arrow - Move to the beginning/end of the previous/next word.
Tab - Lists available commands from the typed text.
Up/Down arows - Shows previous/next command executed.
Ctrl+r - Searches the last command executed from the given text.
Ctrl+c - Stops the current command.
Ctrl+z - Sends the program to the background. Can then be managed using fg/jobs.
Ctrl+d - Logs out from the current terminal. Similar to typing exit.
There are many more, but ones I use a lot:
Repeat/insert the previous command: !!
$ which rename
$ file $(!!)
file $(which rename)
/usr/bin/rename: symbolic link to `/etc/alternatives/rename'
Select words from the previous command: !:1, !:2, etc.
$ ls /var/lib/logrotate/*
$ cat !:1
... contents ...
Fix typo in previous command: ^x^y and ^x
lls: command not found
... listing ...
... long listing ...