LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-26-2007, 05:46 PM   #1
yhus
Member
 
Registered: May 2004
Posts: 75

Rep: Reputation: 15
how to clear bash history at logout


Hi,

I am running Ubuntu. Is there a way to clear history before turning the PC off? I put "history -c" in .bash_logout, it never been called.

Thank you.

Jim
 
Old 09-26-2007, 06:05 PM   #2
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
Remove the history file?

rm ~/.bash_history

I found the history command, but not a history -c.
 
Old 09-27-2007, 03:21 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
A cleaner way is to set HISTFILESIZE equal to 0. You can put
Code:
export HISTFILESIZE=0
in $HOME/.bashrc
 
Old 09-27-2007, 11:04 AM   #4
kromberg
Member
 
Registered: Feb 2007
Location: Colorado
Distribution: FC6, FC7 x86_64
Posts: 218

Rep: Reputation: 30
Quote:
Originally Posted by colucix View Post
A cleaner way is to set HISTFILESIZE equal to 0. You can put
Code:
export HISTFILESIZE=0
in $HOME/.bashrc
That does not saving any history, even when the shell is active. Remove .bash_history in the .bash_logout file as indicated above.

Keith
 
Old 09-27-2007, 11:16 AM   #5
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
This link suggests you could put rm ~/.bash_history in a script in /etc/X11/gdm/PostSession/Default.

Otherwise, changing /etc/init.d/rc.0 to include your rm command should execute it every shutdown (for every reboot, it'd have to be /etc/init.d/rc.6 I believe). See http://ubuntuforums.org/archive/index.php/t-256783.html for more info.

Take care with the last one - messing with the init scripts can lead to non-booting systems. I'd recommend making a backup of all the init.d directory before you do this!
 
Old 09-27-2007, 11:17 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by kromberg View Post
That does not saving any history, even when the shell is active.
Hmmm... the history is kept in memory until you close the shell session. So the last N commands (depending on HISTSIZE) are available for the time the shell is active.

Last edited by colucix; 09-27-2007 at 11:19 AM.
 
Old 09-27-2007, 06:08 PM   #7
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
History Lives Between Sessions?

If I log into my server today, I can count on history tomorrow. Maybe the history is being held a different way, but I didn't add any programming to make that happen.
 
  


Reply



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
How do I clear history in Linux ibrahimt Linux - Security 8 07-14-2009 02:15 AM
How to clear history hi_msh Linux - Newbie 2 01-12-2006 05:40 AM
How do I clear the Dictionary's history? PionexUser Linux - Software 4 11-03-2003 03:18 AM
How does one clear Konqueror's history? forand Linux - Software 9 10-10-2003 01:11 AM
Clear History Mystified Linux - Newbie 1 03-25-2002 09:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:27 AM.

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