By Heidy RamirezJanuary 12th 2021

Know your history

Google is your friend when looking for commands to install software or troubleshoot your system. However, there is another tool that you can use directly on your bash terminal if you are looking for a command you used in the past. This is the history command. This tool by default will save up to 1000 entries of the latest commands that you have inputted on your terminal sessions. If you ever forget a command, just look it up by using the command history.

history

Do you want to see all the latest cat command you have ran just use grep with history

history | grep cat

The history file for each user resides in ~ubuntuuser/.bash_history. Replacing “ubuntuuser” with the actual user.

To clear the history, delete the file and clear the temp history:

rm ~/.bash_history && history -c

The -c option clears the history list by deleting all entries

history –help will display all options that can be used with the history command

The history size by default on Ubuntu is 1000 commands. You can modify this in ~/.bashrc file to set the HISTSIZE variable:

HISTSIZE=<number of entries, -1 for unlimited>

This will not take effect immediately.  You will need to open a new bash shell session.  To apply the new file change do the following:

. ~/ubuntuuser/.bashrc
)