DEV Community

Serhat Teker
Serhat Teker

Posted on Originally published at tech.serhatteker.com on

How to Repeat the Last Command in Linux

You made a typo on your command or you got the error XXX : Permisson denied.

How will you repeat your last command?

If you are a Vim user like me — h, j, k, l is the way and hands should be always on the home row, or just don't want to use default arrow key to get last command, there is an useful command to execute your last command; just
type:

$ !!
🔴 Hot News: serhatteker/how to repeat the last command in linux lo - ประเด็นร้อน 🔴 Hot News: serhatteker/how to repeat the last command in linux lo - ประเด็นร้อน

then press CR | Enter.

In order to execute your previous command with sudo privilege just run:

$ sudo !!
🔴 Hot News: serhatteker/how to repeat the last command in linux lo - ประเด็นร้อน 🔴 Hot News: serhatteker/how to repeat the last command in linux lo - ประเด็นร้อน

All done!

Top comments (0)