Check Terminal History on Linux

Windows Articles

How to install Apache Maven on OpenSUSE 15.2 / 15.1?

In this post, we will show you how to install Apache Maven on OpenSUSE 15.2 / 15.1. To manage projects done in Java, there is...

How to install SQLite on OpenSUSE 15.2 / 15.1?

There are many good database management systems, but they are not all the same. And the fact that they are not, means...

How to detect port scanning and private IP access with Behave

Hello! Security when surfing the internet is a very serious issue. Consequently, the precautions we take are very important. Moreover, web browsers...

How to install LAMP on OpenSUSE 15.2 / 15.1?

It is increasingly common to find small companies that decide to use the SUSE ecosystem for their servers. It's an unsurprising decision because OpenSUSE...

How to use Mytop on Linux?

We already know that both MySQL and MariaDB are among the most popular database managers out there. They have earned this with...

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 –

sudo -s

HISTTIMEFORMAT=”%m/%d/%y %T ”

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 –

history

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)

#!1065

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
HISTSIZE=1000
HISTFILESIZE=1000

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

Enjoy!

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to install Apache Maven on OpenSUSE 15.2 / 15.1?

In this post, we will show you how to install Apache Maven on OpenSUSE 15.2 / 15.1. To manage projects done in Java, there is...

How to install SQLite on OpenSUSE 15.2 / 15.1?

There are many good database management systems, but they are not all the same. And the fact that they are not, means...

How to detect port scanning and private IP access with Behave

Hello! Security when surfing the internet is a very serious issue. Consequently, the precautions we take are very important. Moreover, web browsers...

How to install LAMP on OpenSUSE 15.2 / 15.1?

It is increasingly common to find small companies that decide to use the SUSE ecosystem for their servers. It's an unsurprising decision because OpenSUSE...

How to use Mytop on Linux?

We already know that both MySQL and MariaDB are among the most popular database managers out there. They have earned this with...