LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 04-09-2006, 12:15 AM   #1
keysorsoze
Member
 
Registered: Apr 2004
Location: Queens, NY
Distribution: Red Hat, Solaris
Posts: 295

Rep: Reputation: 30
Checking for users that haven't logged on


Hi! I am currently running a linux system with about 300 users and I wan't to know how to finger everyone to discover their last login times without fingering everyone manually. I would love to get rid of users or lock accounts that have been idle for 4 months without usage. Are there any recommendations anyone could recommend.

Thanks.
 
Old 04-09-2006, 02:57 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Something like
Code:
awk -F: ' $3 > 100 {print $1}' /etc/passwd | xargs finger -s
may get you started...

Or maybe a good look at the output of "last"


Cheers,
Tink
 
Old 04-09-2006, 11:02 AM   #3
keysorsoze
Member
 
Registered: Apr 2004
Location: Queens, NY
Distribution: Red Hat, Solaris
Posts: 295

Original Poster
Rep: Reputation: 30
Hi! Thanks for the command. Is there anyway you could give me a run down of what this does? I ran it and it works but I don't know exactly what it accomplishes.

Thanks.
 
Old 04-09-2006, 01:06 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
Quote:
awk -F: ' $3 > 100 {print $1}' /etc/passwd | xargs finger -s
awk being a text processing language, often used in the same breath as another nice tool called sed.

-F: is using : as a field separator
If you look at the /etc/passwd file, you will see the information separated by colons ( : ) .
You may also notice the third field ( $3 ) is a number from 0 on up. Most if not all distros start regular users with a high number, 500 on Fedora and the example given by Tinkster is saying: When field three is greater than 100 use that match.
Once you have a match, pipe ( | ) that info to the finger command.

From man finger...
-s Force short output format.
 
Old 04-09-2006, 08:23 PM   #5
keysorsoze
Member
 
Registered: Apr 2004
Location: Queens, NY
Distribution: Red Hat, Solaris
Posts: 295

Original Poster
Rep: Reputation: 30
Thanks for the help guys I gotta do some more research on awk this seems to be a very powerful search tool..
Thanks.
 
Old 04-09-2006, 09:02 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
awk is awesome :}

Have a look at the awk-page in our wiki, it also
has a great external link for awk-examples.

Or trawl these pages for my name an awk in the search
text ;} ... may also give you a few nice ideas.


Cheers,
Tink
 
Old 04-16-2006, 03:03 PM   #7
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Code:
last -500 | sort -uk1,1
might also be helpful...
 
Old 04-16-2006, 07:30 PM   #8
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: KirraMail Live Email Server
Posts: 1,285

Rep: Reputation: 61
Quote:
Originally Posted by Tinkster
awk is awesome :}

Have a look at the awk-page in our wiki, it also
has a great external link for awk-examples.

Or trawl these pages for my name an awk in the search
text ;} ... may also give you a few nice ideas.


Cheers,
Tink

You might want to also look at grep and sed as well, very handy tools to have at your disposal
 
Old 04-17-2006, 02:16 AM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by fotoguy
You might want to also look at grep and sed as well, very handy tools to have at your disposal
Heh - thanks for that hint ;}

Personally I'd put awk somewhere between
grep/sed and perl. The things one can do with
either of those in terms of scripting are quite
rudimentary...


Cheers,
Tink
 
Old 04-17-2006, 02:45 AM   #10
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: KirraMail Live Email Server
Posts: 1,285

Rep: Reputation: 61
Quote:
Originally Posted by Tinkster
Heh - thanks for that hint ;}

Personally I'd put awk somewhere between
grep/sed and perl. The things one can do with
either of those in terms of scripting are quite
rudimentary...


Cheers,
Tink

Glad to help

I have only really started to get into scripting the last couple of months, have been doing some stuff over the last couple of years but mainly only recently. I found awk, grep, sed and xargs seem to work so well together, making your scripts come alive, and you get to unleash the full power of linux.
 
  


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
users stays logged in slackamp Slackware 5 01-08-2006 02:54 AM
why so many logged in users? alagenchev Linux - Security 2 03-24-2005 07:19 PM
users who logged before czezz Solaris / OpenSolaris 1 11-24-2004 07:12 AM
No Users logged in X kaise_sose Linux - Software 2 10-19-2004 03:57 AM
New users can't be logged in [RH9] jon_k Linux - Software 3 03-06-2004 02:26 AM

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

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