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:

$ !!
Enter fullscreen mode Exit fullscreen mode

then press CR | Enter.

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

$ sudo !!
Enter fullscreen mode Exit fullscreen mode

All done!

Top comments (0)