How to do a login time and date list of users never logged on?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to do a login time and date list of users never logged on?
# 1  
Old 03-25-2009
How to do a login time and date list of users never logged on?

Hello,
I'm trying to do a list of user that never connected to a couple of servers. I want to do a diff between the servers lists, and print out only the users that never has logged on each server. Here my first step :

SERVER01:
# finger `egrep -v -e "^\s*#" /etc/passwd | awk '{ print $1 }' | sort | uniq` | grep og > login_server01
# perl -n -e ' if ( m/Never/ ) { print $aa.$_ }; $aa =$_ ' < login_server01> never_server01

SERVER02:
# finger `egrep -v -e "^\s*#" /etc/passwd | awk '{ print $1 }' | sort | uniq` | grep og > login_server02
# perl -n -e ' if ( m/Never/ ) { print $aa.$_ }; $aa =$_ ' < login_server02> never_server02

now... how to make a merge between the two files?

really thanks
br
# 2  
Old 03-25-2009
Interesting...

I would have thought people not in login_server file:
Code:
last| sort|cut -d" " -f1|uniq >login_server

would be people never connected (and so compared with users in /etc/passwd)
# 3  
Old 03-26-2009
Smilie yes, it's quite logic...
thanks
# 4  
Old 03-26-2009
Hey, wait there,
You are giving up to fast! Iwas only trying to find another complicated way to accomplish the given task...Smilie
Your reasoning was valid, but lack of practice... finger gives you all you need, you just had to figure out how to use it Smilie
To make it easy I put in script form rather than a one-liner:
Code:
cat /etc/passwd|cut -d: -f1|sort|uniq |while read USER
do
NEVER=$(finger $USER|grep Never)
 if [ "$NEVER" != "" ]
 then
    echo $USER" "$NEVER
 fi
done

Replacing the cat /etc/passwd... by a true users list would be far better (no daemons or other accounts in...)

Last edited by vbe; 03-26-2009 at 09:08 AM.. Reason: spelling...
# 5  
Old 03-26-2009
Thanks, here the last code. Now a diff between the two servers is a little bit easy Smilie
Code:
egrep -v  -e "^\s*#" ./allowed | awk '{ print $1 }' | sort | uniq | while read USER
do
NEVER=$(finger $USER|grep Never)
 if [ "$NEVER" != "" ]
 then
    echo $USER" "$NEVER
 fi
done

br
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to show a list of currently logged in and logging out users?

Hi Guys! I am sure that this question might appeared previously, but I still don't know how to show a list of logged out users. Please help with this! Thanks in advance:) (5 Replies)
Discussion started by: saloliubliu
5 Replies

2. Homework & Coursework Questions

Sort current logged in users by log in time (supposedly to be very easy but I'm missing something)

1. The problem statement, all variables and given/known data: Show all users who are currently logged in, sorted from earliest to latest log in time. The log in time includes the month, day, and time. 2. Relevant commands, code, scripts, algorithms: finger, who, sort, pipe, head, tail, ... (8 Replies)
Discussion started by: vtmd
8 Replies

3. Programming

Get the list of logged in users

How can I get the list of logged in users in the system programmatically? I can get the list with 'who' or 'users' commands but I need to get the list programmatically... May someone help, please? Thanks in advance. (2 Replies)
Discussion started by: xyzt
2 Replies

4. UNIX for Dummies Questions & Answers

Finding users logged on time and space useage

I need to find what users are currently logged onto the system that is easy just a simple who | awk '{ print $1 }' (thats all I need for the part), but I also need to find how long they have been logged on and the total amount of file space they are using. Thanks in advance, I have been looking... (3 Replies)
Discussion started by: mauler123
3 Replies

5. Programming

how can get users list and their login time?

i'm sorry if yesterday i posted this thread in unix for dummies forums, :D i am a newbie in C programming i want to get active users list and their login time... i have search and learn about passwd and utmp, but i only can get user list without their login time... do you have an idea... (2 Replies)
Discussion started by: alif
2 Replies

6. Solaris

List all inactive users who has not logged on since last 90 days

I need actuall script which List all inactive users who has not logged on since last 90 days Thanks in advance. Di! (17 Replies)
Discussion started by: haridham
17 Replies

7. UNIX for Dummies Questions & Answers

List all inactive users who has not logged on since last 90 days

Hi, Can I get a script to list out all the users, who has not logged on since last 90 days. Last command in not working due due to /var/adm/wtmpx is more than 2 GB. Thanks in advance. Regards, Roni (10 Replies)
Discussion started by: manasranjanpand
10 Replies

8. UNIX for Dummies Questions & Answers

last login date and time for all users

I need a command that will list all the users and their last login date & time. I was trying the last command and the who command, but can't get exactly what I need. I just need the output to be user name and last login date . Thanks for your help! (3 Replies)
Discussion started by: igidttam
3 Replies

9. Shell Programming and Scripting

Trying to get list of logged on users sorted

I'm trying to execute a single shell command that will give me a sorted list of all the users currently logged into the system, displaying the users name as it appears in /etc/passwd. I've tried awk -F: '{print $1}' /etc/passwd | xargs finger -s | cut -c11-28 | uniq This list whoever does... (7 Replies)
Discussion started by: kungfuice
7 Replies

10. UNIX for Dummies Questions & Answers

Finding last time users logged in

I would like to find out the last time all users have logged in or out. I tried the last command, but it could not find the wtmp file in /var/adm (I searched in othe directories also). This is an AIX rs6000 4.2.1 system. We are moving our applications from this system to an AIX 5.2 system and I... (11 Replies)
Discussion started by: jyoung
11 Replies
Login or Register to Ask a Question