DEV Community

loading...

How to Repeat the Last Command in Linux

serhatteker profile image Serhat Teker Originally published at tech.serhatteker.com on ・1 min read

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!

Discussion (0)

pic
Editor guide