• 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 Use Clear Command History In Linux Terminal

How To Use Clear Command History In Linux Terminal

By Sourabh / March 18, 2026 Category: How To, Ubuntu

How to use clear command history in Linux terminal. To delete the last 10 lines from your Linux history in the current session, follow the steps given below:

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

How To Find Large Files And Directories In Linux Command Line

Linux Command To Check RAM Size In Ubuntu Terminal In GB

How To Install Proprietary Drivers In Linux Ubuntu Using Terminal

How To Shutdown Linux With A 15 Minute Delay And Message

Free AI Courses With Certificate For Beginners In India

Best AI Plugins For WordPress To Use In 2026

3 Commands To Check USB Connection In Linux Terminal

Linux Terminal Commands for Beginners With Examples

How To Password Protect A Folder In Linux Command Line

Best Download Managers for Ubuntu Linux (2026 Edition)

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

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