Jeffimgcls Hi, I'm Jeff! Resume Linkedin Mail

Delete Bash History

The .bash_history file located in a user’s home directory keeps a history of commands typed in the terminal. If you want to remove that history use the following commands

Delete Entire Bash History

history -c && history -w



Delete Specific Entry in Bash History

$ history -d 

Turn Off Bash History

$ echo "unset HISTFILE" >> /etc/profile


$ echo "unset HISTFILE" >> /home/tom/.bash_profile

Delete A Range of Entries in Bash History

$ for i in {1..N}; do history -d POSITION; done

POSITION is the line number in the history list from where you need to start deleting. N is no of the entries you want to delete. For example to delete 13 entries from line 986, type:

 for i in {1..13}; do history -d 986; done

Clear History Automatically when logging out

echo 'history -c && history -w' >> ~/.bash_logout

©, All rights reserved.