23 C

Check Terminal History on Linux

When you’re running tons of commands every single day, it’s obvious that you may want to keep a track of your terminal activities. For advanced Linux users, this is the burning truth. Well, if your terminal is set to remember history, then checking out the entire history shouldn’t be a problem at all.

Need to find out the history with date and time? Let’s get started!

Checking history

At first, let’s make sure that the time format of the history is set. For that purpose, we have to define an environmental variable “HISTTIMEFORMAT”.

Run the following command –

- Advertisement -
sudo -s


Let’s check out what each of the parts means.

  • %m – Month
  • %d – Day of the month
  • %y – Year
  • %T – Time of the command running

After setting the variable, it’s time to check out the history. Run the following command –


Voila! You can find out the entire history of all the commands you ran previously.

Run command from history

run the command  again  1065 (sudo localctl set-local LANG=en_US.UTF-8)


Control the total number of lines in the history using HISTSIZE

Append the following two lines to the .bash_profile and relogin to the bash shell again to see the change. In this example, only 1000 commands will be stored in the bash history.

# vi ~/.bash_profile

Clear all the previous history using option -c

if you want to clear all the previous history, but want to keep the history moving forward.

# history -c

The command “history” is also highly customizable with various available parameters.

Check out all the available “history” features –

man history


You can also export the man page to a text file for later reading.

man history > ~/Desktop/history.txt


- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"


Please enter your comment!
Please enter your name here

Latest article