• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / How To Clear History In Linux Terminal Permanently

How To Clear History In Linux Terminal Permanently

By Sourabh / October 25, 2023 Category: How To, Ubuntu

In this tutorial we will see how to use clear command history in Linux terminal to delete command history without trace.

We can clear history in Linux terminal permanently, read more to find out how:

How To Clear Command History In Linux

There are three ways to clear command history in Linux Ubuntu:

  1. Clear entire command line history using history command
  2. Clear specific command history using history command
  3. Clear entire command history automatically at logout

Let us learn about each one of these, one by one:

1. Clear Entire Command Line History Using History Command

To clear the entire command line history in terminal, use the history command:

$ history -c

Or

$ history -cw

The above line of commands will clear the command history or bash history.

2. Clear Specific Command History Using History Command

If you want to delete and clear some particular commands from history list (do not want to clear the entire history), run the following command:

First, run the “$ history” command to get the list of run commands along with their command prefix number.

Note down the command number (number infront of each command from the lsit). Now to clear or delete a particular command from the history, run history command with -d paramaeter and the command prefix number (see below):

$ history -d <number>

Note that the represents the command number of each command to be deleted.

3. Clear Command History Automatically at Logout

If you want to clear bash history automatically at logout you will have to edit ~/.bashrc file. Open and edit the file using the following command:

$ vi ~/.bashrc

Once the file is opne, add the following line:

unset HISTFILE

Now save and close the file.

That’s all now the bash history will be automatically deleted and cleared after you logout from the current session.

Primary Sidebar

Latest Posts

Ubuntu 25.04 ‘Plucky Puffin’ Is Available To Download

How to Login as Root User in Linux Terminal

Install Firefox In Ubuntu Terminal Command Line

How To Check Kernel Installed Date In Linux Ubuntu

How To List All Kernel Modules That Are Loaded In Ubuntu

Enable Ubuntu Auto Login Without Password

Download Ubuntu 25.04 Official Default Wallpapers

How To Fix Initramfs Error In Ubuntu Command Line

How To Check All Available Kernel Version In Linux Ubuntu

3 Best Artificial Intelligence Domain Name Generators

© 2025 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap