Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Security
User Name
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.


Closed Thread
  Search this Thread
Old 07-30-2004, 01:26 PM   #1
LQ Newbie
Registered: Jul 2004
Location: nigeria
Distribution: mandrake
Posts: 4

Rep: Reputation: 1
How do I clear history in Linux

Hello all,

Please can anybody help me with a command to clear history of all the command I ever typed from command prompt in Linux. I share a system with a number of people that access the system with the same username. I wouldn't want somebody to re-execute a command that I had already executed before either by mistake or intentionally.

I have tried using "man history" on mandrake 9.1 but did not give me any result. I also searched the web without success.

Thanks in advance

Old 07-30-2004, 01:49 PM   #2
Registered: Jul 2004
Location: Woodland Hills, CA
Distribution: Debian/Mandrake
Posts: 37

Rep: Reputation: 15
Depends on which shell you use...but the most common is bash, and I believe it is the default... Chances are, anyway.

If you change to your home directory, and do:
ls -al

You should see a file called: .bash_history

That file will contain all (maybe just most, can't remember what the cap is, if any) of the command line history.

To clear it, like you want, you can simply delete that file.
Old 07-30-2004, 01:51 PM   #3
Registered: Apr 2004
Location: berkeley, ca
Distribution: slk10, winxp
Posts: 313

Rep: Reputation: 30
if you use bash, there's .bash_history in your home directory, remove it. if you use another shell, look for a similar file.

--posting at the same time--
Old 08-03-2004, 01:36 AM   #4
Registered: Aug 2004
Distribution: Slackware 10
Posts: 110

Rep: Reputation: 15
I personally like to set an alias to do this it's always set as...

alias history="rm .bash_history"
Old 08-03-2004, 08:14 AM   #5
LQ Newbie
Registered: Aug 2004
Location: US
Posts: 27

Rep: Reputation: 16
use history -c to clear everything
1 members found this post helpful.
Old 08-03-2004, 08:20 AM   #6
Senior Member
Registered: Mar 2003
Location: Beautiful BC
Distribution: RedHat & clones, Slackware, SuSE, OpenBSD
Posts: 1,791

Rep: Reputation: 50
edit your .bashrc and add


Of course, you will not be able to use the up-arrow to retrieve your previous command. OR set HISTSIZE to something that will allow minimum exposure.
Old 08-03-2004, 10:44 AM   #7
LQ Newbie
Registered: Jul 2004
Location: nigeria
Distribution: mandrake
Posts: 4

Original Poster
Rep: Reputation: 1
Thanks all,

all the suggestions worked as explained. I found "history -c " command most straight-forwad. Thaks to everybody once again

1 members found this post helpful.
Old 07-14-2009, 03:09 AM   #8
LQ Newbie
Registered: Jul 2009
Posts: 1

Rep: Reputation: 2
Thumbs up

Originally Posted by liinux View Post
use history -c to clear everything
Thanks alot, it's really helpful
2 members found this post helpful.
Old 07-14-2009, 03:15 AM   #9
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Originally Posted by dr.ash View Post
Thanks alot, it's really helpful
dr.ash, please don't resurrect dead threads.

BTW, there's a Thanks button attached to every post, for when you are feeling thankful.
1 members found this post helpful.

Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
history clear command suguname Linux - Newbie 5 03-05-2005 10:32 AM
How do I clear all my RedHat 9 History? PionexUser Linux - General 1 11-20-2003 11:42 AM
How do I clear the Dictionary's history? PionexUser Linux - Software 4 11-03-2003 04:18 AM
How does one clear Konqueror's history? forand Linux - Software 9 10-10-2003 02:11 AM
Clear History Mystified Linux - Newbie 1 03-25-2002 10:27 AM > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 09:34 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration