• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
The Electric Toolbox Blog

The Electric Toolbox Blog

Linux, Apache, Nginx, MySQL, Javascript and PHP articles

  • Applications
  • FCKEditor
  • Apache
  • Windows
  • Contact Us
Home / Clear the bash history

Clear the bash history

When entering commands in a bash shell each command is stored in the history which is written to the .bash_history file when logging out. This post shows how to clear the history for the current session, and how to clear all commands completely from the history.

Clearing the history for the current session

The first command below will clear the history for the current session only, resetting it back to how it was when you first logged in.

history -r

Any additional commands entered after running this will be added to the history.

Clearing everything from the history

To completely empty the history enter this command:

history -c

As with "history -r", any additional commands entered after this will be added to the history.

Note that the .bash_history file is only written to when you log out. So although the entire history in memory has been cleared, it still remains in the file until logging out. To ensure your history file is emptied immediately, run "history -c" and then log out from all active shells to the server.

Check Out These Related posts:

  1. How to Install Linux screen
  2. Bash Check if File Exists
  3. PageUp and PageDown history search auto completion on the BASH shell
  4. History search auto completion on the BASH shell on Ubuntu

Filed Under: Linux/Unix/BSD

Primary Sidebar

Categories

  • Apache
  • Applications
  • Article
  • Case Studies
  • Email Servers
  • FCKEditor
  • HTML And CSS
  • Javascript
  • Linux/Unix/BSD
  • Microsoft SQL Server
  • Miscellaneous Postings
  • MySql
  • Networking
  • Nginx Web Server
  • Offsite Articles
  • OSX
  • PHP
  • Quick Tips
  • RFC – Request for Comments
  • SilverStripe
  • VMWare
  • VPN
  • Windows
  • WordPress

Recent Posts

  • Vim Show Line Numbers
  • Add User To Group Linux
  • Chmod 777 Tutorial
  • How to Copy Directory Linux
  • Linux create user

Copyright © 2021. ElectricToolBox. All Rights Reserved.

  • Contact Us
  • Copyright Info
  • Privacy Policy
  • Sitemap