I am fairly new to Linux and I need to find a way to show the contents of my Bash History via the command line, and unfortunately I can't seem to find anything that works, or that I can understand. I am using Linux Ubuntu 11.10, and when I open the Bash History manually by finding the file, it opens with something known as gedit. How will I be able to view the contents of my Bash History via the command line? Many Thanks! ~ShadedVeil
Asked
Active
Viewed 9,239 times
2 Answers
0
$history
and it will show the history
1999 exit
2000 cd /opt
2001 sudo apt-get install p7zip-full
2002 sudo apt-get install p7zip-rar
2003 mkdir CS-RT-code
2004 cd CS-RT-code/
2005 ls -lrt
2006 history
$ !<history #> to execute the previous history command

Ashu
- 3,966
0
less
is a pretty useful command evolved from more
. You can use it to browse through large text files. Run:
less $HOME/.bash_history
Use the Up/Down arrow keys to go up and down in the file. Press q
to exit.
For more information/keyboard shortcuts in less
, run man less
. It will show its manual pages.
For instance, you could also use other utilities, such as cat
(cat $HOME/.bash_history
), more
(more $HOME/.bash_history
), nano (nano $HOME/.bash_history
) and Vim (vim $HOME/.bash_history
).

Eduardo Cola
- 5,817
sudo nano ~/.bash_history
this will allow you to open up yourbash_history
and go through it – Alex Lowe Feb 11 '16 at 21:56sudo
from the command so it would look like thisnano ~/.bash_history
– Alex Lowe Feb 11 '16 at 22:06history | grep ls
which will find all of the times that you have run the commandls
– Alex Lowe Feb 11 '16 at 22:08