LinuxQuestions.org
Review your favorite Linux distribution.
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 10-20-2010, 10:45 AM   #1
legaboka
LQ Newbie
 
Registered: Oct 2010
Posts: 6

Rep: Reputation: 0
Question Administration


HI

How do we check if a particular user has logged off. I only know how to check if a user logged in either by using who, w or last but don'thave an idea of how to check if a user has logged off.

Any idea?
 
Old 10-20-2010, 11:36 AM   #2
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 14.04
Posts: 434
Blog Entries: 1

Rep: Reputation: 45
you can check doing:

last <username> and that will list all the sessions od that user.

hope that helps
 
Old 10-20-2010, 12:32 PM   #3
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
I don't quite see what your problem is...
Code:
who -u | grep "user"
should tell you if a user is logged in or not - if it produces output, then that user is logged in. If there is no output, then that user isn't logged in.

Or am I misunderstanding you?
 
Old 10-21-2010, 05:03 AM   #4
legaboka
LQ Newbie
 
Registered: Oct 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Snark1994 View Post
I don't quite see what your problem is...
Code:
who -u | grep "user"
should tell you if a user is logged in or not - if it produces output, then that user is logged in. If there is no output, then that user isn't logged in.

Or am I misunderstanding you?
What i mean is that, the script should detect if a certain user has logged off and also inform me which user logged off.

when using last to check those who logged in, it indicates that by a phrase "still logged in" and I want to know how i can see if one of the users who logged in has logged off/out.

Thanks
 
Old 10-21-2010, 05:21 AM   #5
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,145
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
who -u |grep -i "user"> /dev/null
if [ $? -eq 0 ];
then
echo "User is Logged In";
else
{
echo "User Logged Off"
}
fi

Also note if user is never logged in then also it will say User logged off
 
  


Reply


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
linux system administration including network administration linux_linux Linux - Hardware 3 03-15-2008 11:07 PM
LXer: System Administration Toolkit: Distributed administration using SSH LXer Syndicated Linux News 0 08-15-2007 08:20 AM
Administration jwymore Fedora 2 02-08-2007 08:02 AM
"Essential System Administration" or "UNIX System Administration Handbook"? TGWDNGHN Linux - Newbie 3 07-03-2005 09:27 PM
Administration csevey Linux - General 4 08-31-2003 01:30 PM

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

All times are GMT -5. The time now is 05:05 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration