How To Clear Shell History In Ubuntu Linux ?

When you type something on linux shell, by default Linux save the commands what you type as history to “~/.bash_history” or /home/username/.bash_history file so that you can easily check what you have typed previously using “history” command.

 $ history | tail
 1998  sudo apt-get install mdns
 1999  sudo apt-get install mdns-scan
 2000  sudo mdns-scan

As you can see, we just showed last output of “history” command. You can use only “history” without “tail” to see all the complete history.

Clearing history

The easiest way to clear history is to use “history -c” command for the current terminal. This command only clears history of current terminal and if you close the terminal and start again, you will see the last saved history from “~/.bash_history” file.


Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )

   


$ history -c

If you want to wipe-out all the history so that even after restarting of terminal it shouldn’t show any details, you will need to clear the “~/.bash_history” file contents.

$ echo "" > ~/.bash_history

Now, if you close and open the terminal, you will not see any history.

lynxbee_ezoic

Leave a Comment

Android Android Build system Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded