Pytest Fixtures
Pytest Fixtures
January 24, 2023
Execution of a command in bash without saving it
Execution of a command in bash without saving it
February 7, 2023

January 31, 2023

Linux Easy Way to Use Previous Commands

While working in command terminal, we may want to re-enter a command we entered before. We can repeatedly press the up key on our keyboard until we find the wanted command, but sometimes it can be better to use the history command instead. This command lists all the commands we entered since the first terminal launch:

$ history
 ...
 2009  date
 2010  history
 2011  uname

Each line have a number and a matching command.

We can re-enter those commands by simply typing:

$ !#

Where # should be substituted with the matching number of the command wanted to be re-executed in the command history.

$ !2009
date
Fri Oct 21 14:31:54 +03 2022

If the command you want to run requires sudo privileges, you can simply type:

$ `sudo !#` 

PS: You can re-execute last command with super user privilegesvia the following command:

$ sudo !!
Linux Easy Way to Use Previous Commands
This website uses cookies to improve your experience. By using this website you agree to our Data Privacy Statement
Read more