LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-14-2007, 03:05 AM   #1
tanveer
Member
 
Registered: Feb 2004
Location: e@rth
Distribution: RHEL-3/4/5,Gloria,opensolaris
Posts: 525

Rep: Reputation: 39
who gave the last reboot command in ssh


hi all,
Is there any way to know who gave the last reboot command whether remotely through ssh with IP or locally?

thanks in advance.
 
Old 08-14-2007, 03:50 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Have you checked the output of 'last'? It shows who logged on, when and at what times the machine was rebooted. If you use the -d switch, it should output the IP addresses of those who were remotely logged in. Check the man page for more info.

edit: I think what you may be looking for is:
Code:
last -d reboot

Last edited by pwc101; 08-14-2007 at 03:51 AM.
 
Old 08-14-2007, 04:18 AM   #3
tanveer
Member
 
Registered: Feb 2004
Location: e@rth
Distribution: RHEL-3/4/5,Gloria,opensolaris
Posts: 525

Original Poster
Rep: Reputation: 39
Output:-
Code:
[root@phobos ~]# last -d reboot
reboot   system boot  0.0.0.0          Tue Aug 14 13:01          (02:06)
reboot   system boot  0.0.0.0          Sat Aug 11 15:58         (2+21:01)
reboot   system boot  0.0.0.0          Sat Aug 11 14:32          (01:23)
reboot   system boot  0.0.0.0          Sat Aug 11 14:16          (00:14)
reboot   system boot  0.0.0.0          Sat Aug 11 13:37          (00:37)
reboot   system boot  0.0.0.0          Sat Aug 11 13:32          (00:04)
reboot   system boot  0.0.0.0          Sat Aug 11 13:28          (00:02)
reboot   system boot  0.0.0.0          Sat Aug 11 13:25          (00:01)
reboot   system boot  0.0.0.0          Sat Aug 11 12:59          (00:24)
reboot   system boot  0.0.0.0          Sat Aug 11 09:38          (03:19)
reboot   system boot  0.0.0.0          Thu Aug  9 18:25         (1+15:00)
reboot   system boot  0.0.0.0          Thu Aug  9 16:25          (01:47)

wtmp begins Wed Aug  1 17:11:51 2007
Code:
[root@phobos ~]# last reboot
reboot   system boot  2.6.9-22.ELsmp   Tue Aug 14 13:01          (02:08)
reboot   system boot  2.6.9-22.ELsmp   Sat Aug 11 15:58         (2+21:01)
reboot   system boot  2.6.9-22.ELsmp   Sat Aug 11 14:32          (01:23)
reboot   system boot  2.6.9-22.ELsmp   Sat Aug 11 14:16          (00:14)
reboot   system boot  2.6.9-22.ELsmp   Sat Aug 11 13:37          (00:37)
reboot   system boot  2.6.9-22.ELsmp   Sat Aug 11 13:32          (00:04)
reboot   system boot  2.6.9-22.ELsmp   Sat Aug 11 13:28          (00:02)
reboot   system boot  2.6.9-22.ELsmp   Sat Aug 11 13:25          (00:01)
reboot   system boot  2.6.9-22.ELsmp   Sat Aug 11 12:59          (00:24)
reboot   system boot  2.6.9-22.ELsmp   Sat Aug 11 09:38          (03:19)
reboot   system boot  2.6.9-22.ELsmp   Thu Aug  9 18:25         (1+15:00)
reboot   system boot  2.6.9-22.ELsmp   Thu Aug  9 16:25          (01:47)

wtmp begins Wed Aug  1 17:11:51 2007
 
Old 08-14-2007, 04:22 AM   #4
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Rep: Reputation: 30
Dear pwc101,
Yes its works . But i got the following results.
reboot system boot 0.0.0.0 Tue Aug 14 14:08 (00:46)
reboot system boot 0.0.0.0 Tue Aug 14 12:31 (01:34)
reboot system boot 0.0.0.0 Tue Aug 14 11:04 (03:01)
reboot system boot 0.0.0.0 Mon Aug 13 15:10 (01:45)
reboot system boot 0.0.0.0 Mon Aug 13 08:42 (08:13)
reboot system boot 0.0.0.0 Sun Aug 12 20:28 (00:50)
No IP displayed. The top one i had restarted it through remote login. Please explain is there a way to find it out?
 
Old 08-14-2007, 04:50 AM   #5
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Try:
Code:
last -i reboot
 
Old 08-14-2007, 06:49 AM   #6
tanveer
Member
 
Registered: Feb 2004
Location: e@rth
Distribution: RHEL-3/4/5,Gloria,opensolaris
Posts: 525

Original Poster
Rep: Reputation: 39
the output is same as last -d reboot
 
Old 08-14-2007, 06:52 AM   #7
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Sorry, no idea then.

edit: Have you checked your DNS server or /etc/hosts file is set up correctly?
 
Old 08-14-2007, 07:13 AM   #8
tdbabar
LQ Newbie
 
Registered: Jul 2007
Distribution: RedHat
Posts: 17

Rep: Reputation: 0
'last' command shows the login usernames, not the commands.
You could check the history, but its difficult to makeout, what you need......

Last edited by tdbabar; 08-14-2007 at 07:14 AM.
 
Old 08-14-2007, 07:46 AM   #9
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
Actually, last report the boot up, not the shutdown. And since there is still not an active internet connection, nor a user logged in, it only reports the kernel which has initiated the boot process. This is why you see 0.0.0.0 when using the -d option.
On Redhat/Fedora you can have some information on who was logged in immediately before the shutdown looking at /var/log/message and /var/log/secure together. In /var/log/secure you will see messages like (if pam auth enabled):
Code:
Aug  1 08:41:23 server-2 su: pam_unix(su:session): session closed for user root
Aug  1 08:41:23 server-2 gdm[3124]: pam_unix(gdm:session): session closed for user palm
which tell you who was logged in at shutdown time, but not actually who performed the shutdown command.
 
Old 08-14-2007, 08:08 AM   #10
yanik
Member
 
Registered: Oct 2003
Location: Montreal Beach
Distribution: Debian Unstable
Posts: 368

Rep: Reputation: 30
I had a similar experience. But since I changed the root password and setup sudo. Sudo logs everything. I even set it up to send me an email when people use sudo.

Add this to sudoers

Code:
Defaults        mailto="you@yourdomain.com"
Defaults        mail_always
Defaults        log_year, logfile=/var/log/sudo.log
When someone uses sudo, I get an email like this one:


Quote:
pspfc : Aug 13 01:00:22 2007 : root : TTY=unknown ; PWD=/ ; USER=mgr ; COMMAND=/home/portfolio6/conv/jbascule
So you can see user mgr used sudo to execute /home/portfolio6/conv/jbascule on machine pspfc


To make sure they don't bypass sudo, I also added this to sudoers:

Code:
Cmnd_Alias      SHELLS = /bin/csh, /bin/jsh, /bin/ksh, /bin/pfcsh, /bin/pfksh, /bin/pfsh, /bin/rksh, /bin/rsh, /bin/sh, /bin/tcsh, /bin/zsh, /usr/bin/csh, /usr/bin/jsh, /usr/bin/ksh, /usr/bin/pfcsh, /usr/bin/pfksh, /usr/bin/pfsh, /usr/bin/rksh, /usr/bin/rsh, /usr/bin/sh, /usr/bin/tcsh, /usr/bin/zsh

%wheel  ALL=PASSWD:ALL, !SHELLS, PASSWD:/usr/bin/su [!-]*, !/usr/bin/passwd root, !/usr/bin/su root
 
  


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
ssh denies putty after windows reboot kav Linux - Networking 3 03-20-2007 09:14 AM
Debian SSH does not start on reboot renegadeavenger Debian 5 01-31-2007 09:50 AM
Can't reboot via ssh, but can from local terminal xymian Linux - Networking 2 09-05-2005 10:04 AM
reboot when "reboot" command not responding? neocookie Linux - General 1 08-30-2005 04:59 AM
Reboot from ssh v00d00101 Linux - Newbie 3 07-09-2003 02:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:49 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