LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-24-2011, 01:49 PM   #1
Robert G
LQ Newbie
 
Registered: May 2011
Posts: 5

Rep: Reputation: Disabled
How do you clear reboot history?


I don't mind a few lines of reboots, but this is getting rather long:

Last login: Tue May 24 11:24:31 2011
Rebooted at 10:14AM 03/25/10 2.6.18-164.el5
Rebooted at 11:13AM 04/22/10 2.6.18-164.el5
Rebooted at 10:54AM 06/01/10 2.6.18-164.el5
Rebooted at 16:19PM 08/12/10 2.6.18-164.el5
Rebooted at 17:02PM 08/16/10 2.6.18-164.el5
Rebooted at 10:38AM 08/19/10 2.6.18-164.el5
Rebooted at 10:46AM 10/05/10 2.6.18-164.el5
Rebooted at 13:21PM 11/11/10 2.6.18-164.el5
Rebooted at 17:35PM 12/15/10 2.6.18-164.el5
Rebooted at 18:55PM 02/16/11 2.6.18-164.el5
Rebooted at 14:01PM 02/17/11 2.6.18-164.el5
Rebooted at 14:27PM 02/21/11 2.6.18-164.el5
Rebooted at 10:57AM 05/23/11 2.6.18-164.el5
Rebooted at 11:05AM 05/23/11 2.6.18-164.el5

How can I clear (or reduce) the history that comes up when ssh to my host?
 
Old 05-24-2011, 02:46 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
You can just change the 'last reboot' in your profile to specify the number of entries you want to see. For example, 'last -n3 reboot'. You can change your /etc/logrotate.conf to reduce the rotation interval for /var/log/wtmp, if you just want to keep less data.
 
Old 05-24-2011, 03:28 PM   #3
Robert G
LQ Newbie
 
Registered: May 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thank you, but need more information. Where do I change 'last reboot' in my profile?
 
Old 05-24-2011, 03:43 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi there,

You can run the following commands to clear up the history:

mv /var/log/wtmp /var/log/wtmp.old && touch /var/log/wtmp

Remember this will clear up all history because you are renaming the file (wtmp is the file use to log reboot, login etc history) using the above command and at the same time you are creating a new one for future logging.

chown root.utmp /var/log/wtmp && chmod 664 /var/log/wtmp

The above command will change the ownership to root and group assignment to utmp for logging and at the same time assign rw-rw-r-- permission on /var/log/wtmp

I hope this helps.
 
1 members found this post helpful.
Old 05-24-2011, 03:50 PM   #5
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Quote:
Originally Posted by Robert G View Post
Thank you, but need more information. Where do I change 'last reboot' in my profile?
Most distributions don't list the last reboot. If you or someone you know didn't add it, you'll need to look around to see where it was added. The possible locations vary with the shell. If you're using bash, then check:

~/.bashrc
~/.bash_profile
/etc/bashrc
/etc/profile
and the files in /etc/profile.d/
 
Old 05-24-2011, 04:31 PM   #6
Robert G
LQ Newbie
 
Registered: May 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks guys, but... Could not grep 'last reboot' (or variations) anywhere in those listed files (yes, using bash). And, followed T3RM1NVT0R advice, but it didn't fix it.

my.desktop% ls -ltr wtmp*
-rw-rw-r-- 1 root utmp 812160 May 24 13:21 wtmp.old
-rw-rw-r-- 1 root utmp 1536 May 24 14:24 wtmp

Still getting the entire list of reboots when I ssh to my host. (using Putty btw) This is a corporate linux host. Can it be controlled by corporate policies?

hmmm, anything else I can try?

Last edited by Robert G; 05-24-2011 at 04:35 PM.
 
Old 05-24-2011, 04:54 PM   #7
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi Robert,

Well doing ssh via putty should not be an issue.

I tried it once again on my RHEL and Linux Mint system and it worked perfectly fine. You can give a try by breaking down the commands. Run them in the following sequence and see if you still get the message:

1. mv /var/log/wtmp /var/log/wtmp.old
2. ls -l | grep /var/log/wtmp (just to make sure that the file has been renamed)
3. touch /var/log/wtmp
4. chown root.utmp /var/log/wtmp
5. chmod 664 /var/log/wtmp

Last edited by T3RM1NVT0R; 05-24-2011 at 04:56 PM.
 
Old 05-24-2011, 04:57 PM   #8
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
As root, run

/dev/null > /var/log/wtmp

which effectively overwrites wtmp with nothing (/dev/null), leaving an empty wtmp file.

You may get an error messages that says "permission denied". However, if you run "ls -l /var/log/wtmp" you will see that the file is empty.

If the list of reboots still displays, then the history is not stored in wtmp. In an effort to find the offending log file, try this as root:

find /var -type f | grep -i reboot
or perhaps
find /var -type f | xargs grep -i reboot
 
Old 05-24-2011, 06:19 PM   #9
Robert G
LQ Newbie
 
Registered: May 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
T3RM1NVT0R:

No error, as you can see from the files listed, it worked. I used sudo to run the commands, as I do not have permissions as user. I have a new wtmp file that is 1.5k in size, compared with the old file that is 812k.

my.desktop% ls -ltr wtmp*
-rw-rw-r-- 1 root utmp 812160 May 24 13:21 wtmp.old
-rw-rw-r-- 1 root utmp 1536 May 24 14:24 wtmp

I can even view the wtmp.old file and see the binary that looks like it logged the reboots, while the new wtmp file doesn't have much in there yet.

bigrigdriver:

Tried find commands and found:

my.desktop% sudo find /var -type f | grep -i reboot
/var/cfengine/inputs/default/reboot_count/reboot_count.cf
 
Old 05-24-2011, 06:28 PM   #10
Robert G
LQ Newbie
 
Registered: May 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
OMG found it. The key was the reboot_count.cf file. Which led me on a hunt through a few scripts with lots of variables. Finally found the trail.

Reboots are held in the file called /etc/motd.local. I replaced that file and it is now working.

Thanks guys for the tips. Couldn't have found it without you!
 
  


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
Is it possible to clear Synaptic history? Mr. Alex Linux - Software 1 06-13-2010 05:43 PM
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
Clear History Mystified Linux - Newbie 1 03-25-2002 09:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:04 PM.

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