Q. I just noticed faq about clearing dns cache and there are lots of commands stored in my cache. Can you tell me the command to clear out my command history or cache from a shell prompt?
A. Many programs read input from the user a line at a time. The GNU history library is able to keep track of those lines, associate arbitrary data with each line, and utilize information from previous lines in composing new ones. Bash and other shell may use this history library. The default fie is ~/.history or ~/.bash_history.
To display the history list with line numbers, enter
$ history
Output:
....
..
4 cd /tmp/
5 wget http://downloads.wordpress.org/plugin/cleaner-dashboard.1.1.zip
6 unzip cleaner-dashboard.1.1.zip
7 su -
8 vi /etc/httpd/testing.lan.cyberciti.biz.conf
9 service httpd restart
.....
..
997 vnstat -m -i eth1
998 date
999 yum update
1000 w
1001 ~/scripts/clean.cache rss squid web
1002 historyNote: Lines listed with the a * have been modified.
To clear the history, enter:
$ history -c
The -c option causes the history list to be cleared by deleting all of the entries. For more information, enter:
$ help history
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 12 comments… read them below or add one }
I have found this site very useful which comes with straight forward explanations, thanks a lot. morgen musonza
Hi, Thank you very much.
I also found in your site very useful, I am newcomer to linux operating system.
Perfect!!!
Thanks.
Thanks this is just what I was looking for.
There’s also the ~/.bash_history file that still needs to be deleted.
Really. Good.
Its good n helpful
Also you can make alias like
alias clearhist=’rm ~/.bash_history;history -c;exit’
This clear everything without leaving any sort of trail :)
Thank u,
nice command
I’m running konsole on a linux system. Evidently, when I did ‘Settings->Save as Default’ in the konsole shell, there were 30 lines of commands in the history at that time. Now, when I start a new shell and issue first command: history, those 30 lines are displayed. I have tried removing different files in the ~/.kde/share/config/ dir, and this will clear the saved schema but not the history. I have tried ’rm ~/.bash_history;history -c;exit’ as stated above and still no change.
Does anyone know where that old history is stored and how on earth I can remove it?
Many thanks
Thanks for the command reference. It worked great.