LINUX KEYBOARD TERMINAL SHORTCUTS

Linux Keyboard Terminal Shortcuts (Ubuntu etc)

CRTL+_Undo
CTRL + r Recall the last command including the specified character(s) searches the command history as you type.
ALT+(left or right arrow) Move back/forward by word
CTRL+xx Toggle between the start of line and current cursor position
Ctrl + k Cut the Line after the cursor to the clipboard
Ctrl + u Cut/delete the Line before the cursor to the clipboard.
Alt + d Delete the Word after the cursor.: Alt + d
Ctrl + w Cut the Word before the cursor to the clipboard.
CTRL+L Clear Screen
CTRL+D Exit
!! Repeat last command
sudo !! Repeat last command AS ROOT
!$ (Reuse last word (last argument) from previous command)
If you type say:
ls -l /tmp/some_log/LastSharedMemoryAndSerialOutput.log
and then type:
cat !$
=>The gets the 2nd component of the previous command i.e. it is the same as:
cat /tmp/some_log/LastSharedMemoryAndSerialOutput.log
!!:N (Reuse the Nth word from a previous Command)
echo one two three four
echo !!:2
same as saying:
echo two
Repeat last command that started with the string
e.g if you type:
whoami
ls -l
top
=>
Example 1
then type:
!w }i.e. 1st letter of the command you recently typed
(or you could type say !wh) }i.e. 1st and 2nd letters of the command you recently typed
=>Same as saying=>whoami
Example 2
!l }i.e. 1st letter of the command you recently typed
=>same as saying=>
ls -l
Wipe a file clean
echo "" > file_you_want_to_wipe.txt
You can just write this as:
> file_you_want_to_wipe.txt

Linux Create Multiple Files Shortcut
touch file{1..3}.txt
=
touch file1.txt
touch file2.txt
touch file3.txt

Linux Move Files Shortcuts
mv file1{.txt,.log}
=
mv file1.txt file1.log


mv file2.{txt,log}
=
mv file2.txt file2.log


touch jazz } If you have a file with no extensions like this…
mv jazz{,.txt}
=
mv jazz jazz.txt





Linux Examples - Comments