Useful linux commands

Useful linux commands

Fix typos in the command line

1
2
dp *.txt /var/tmp
^dp^cp

Find commands that you don’t know

1
apropos "mount file"

Execute command from bash history

Execute the last executed command

1
!!

Execute the command with all the arguments passed to the previous command

1
!*

Get the first argument of the last executed command

1

Get the last argument of the last executed command

1
!$

Execute the third command in bash history

1
!3

Use comma and braces to simplify commands

Backup system.yaml to system.bak

1
cp system.yaml{,.bak}

Restore it

1
mv system.yaml{.bak,}

Copy a file, with target filename with prefix ‘bak’

1
cp system.yaml bak-!#^

Display process tree

1
ps -aux -forest

Ncdu - ncurses disk usage analyzer

1
2
sudo apt-get install ncdu
ncdu

Share