Bash history

itsmohamedyahia

Mohamed Yahia

Posted on October 8, 2023

Bash history

You can scroll the history of the commands you run by the up and down arrows in the terminal.

But in case you would like to look at the list of the comamnds you run you can type run history. It will print the commands in the terminal.

You can view them using less program by piping history to less history | less.

Once you find the command you woould like to re-run just exit if you are in less type ! followed by the line number of the command.

What you have done now is called history expansion. It is called like that because !1345 is expanded into the full command at the line number in the history file corresponding to the number you wrote.

The list file is located in the home directory under the name .bash_history

💖 💪 🙅 🚩
itsmohamedyahia
Mohamed Yahia

Posted on October 8, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related