I was doing an assignment on Ubuntu that requires screenshots of my commands. But my laptop shut down and the program closed without me taking the screenshots. Is there a way to retrieve my previous commands on Ubuntu?

  • check your bash history file - maybe u r lucky. less ~/.bash_history Apr 25, 2022 at 19:07
  • 1
    There is a command for that ----> history
    – Raffa
    Apr 25, 2022 at 19:08

2 Answers 2


You can find them in ~/.bash_history.

Note that ~/ refers to your home folder.

The full path would be, /home/<your-username>/.bash_history


It addition to what others have said here, if you want to see them one at a time, just press the up-arrow key when you are in your terminal. This will display them one at a time. (Hitting enter will re-execute the command, as well.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .