No! Clear Linux history

History on any Linux box is handy to recall old command and you can see what happened on the server over a time frame. Some times things that we deemed as handy could become an security risk to us all. My personal advise would be is to check your history on your personal account and especially on the root account. We are all Human and can enter sensitive information i.e a password in the wrong place. By clearing the screen so no one behind you can see; it it still remains in your history. Remember Linux is not as scary as most non Linux users think. If in doubt, you can always check the Man pages in Linux to help you if not “g00gle”; “Bing” (LOL) and other search engines will help.

[server name ~] $ history


This will list all the history on your machine. TIP! if the list is running off the screen you can pipe (|) out to more or less as  quick way.

To clear all history under your profile you can run:

history -c {this clear all the history and work on Mac as well}

I personally only clear out lines in the history file which i deemed as risky, incorrect and out of date. To do this, it is:

history -d <Line Number>


A few more “Tips”:

To view your history in a editor (to save for later), just type:

history -w ~/history.txt
vim ~/history.txt
history -w ~/history.txt this saves the history to a file named history.txt on your home folder (cd ~/). The next command opens up the file for viewing in vim.

man history
Now to change your bash history length, just open up your .bashrc by doing so:

vim ~/.bashrc
Once open, at the top add.

export HISTFILESIZE=3500
As you can see, the limit can be changed.

Bash keeps it’s own history in a file. You can view that file as stated before, or by opening ~/.bash_history

You can search through your bash_history by piping your history file into grep like so:

history | grep “search term here”

history | grep “wget”

Enjoy my friends. Keep on embracing  Technology. It has no barriers and a phenomenal tool set.




Privacy Preference Center