Check Terminal History on Linux

Windows Articles

PHP 8.0 available

PHP is one of the easiest open source programming languages to learn. Similarly, PHP is very popular and suitable for website development and can...

How to install PHP 8 on Ubuntu 20.04 / Debian 10?

Hello, friends. In this post, you will learn how to install PHP 8 on Ubuntu 20.04 / Debian 10. This way, you will be...

Learn how to control the volume of Windows using the mouse wheel.

Hi! Windows recently celebrated its 35th anniversary. Therefore, it is one of the longest lasting and most used systems currently. On the other hand,...

Install Nim programming language on Ubuntu 20.04 / Debian 10

Nowadays, almost everything is done with the help of a computer and a program. And the programs are made through a programming language. That...

Configure Samba File share Services with Ubuntu 20.04 LTS

Here, Today! let's discuss samba file share service with Ubuntu 20.04 LTS. If you need to share files between Linux and MS Windows...

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

PHP 8.0 available

PHP is one of the easiest open source programming languages to learn. Similarly, PHP is very popular and suitable for website development and can...

How to install PHP 8 on Ubuntu 20.04 / Debian 10?

Hello, friends. In this post, you will learn how to install PHP 8 on Ubuntu 20.04 / Debian 10. This way, you will be...

Learn how to control the volume of Windows using the mouse wheel.

Hi! Windows recently celebrated its 35th anniversary. Therefore, it is one of the longest lasting and most used systems currently. On the other hand,...

Install Nim programming language on Ubuntu 20.04 / Debian 10

Nowadays, almost everything is done with the help of a computer and a program. And the programs are made through a programming language. That...

Configure Samba File share Services with Ubuntu 20.04 LTS

Here, Today! let's discuss samba file share service with Ubuntu 20.04 LTS. If you need to share files between Linux and MS Windows...
x