Operating System - Linux
1826333 Members
3601 Online
109692 Solutions
New Discussion

Shell Script needed...for user account details

 
girishb
Frequent Advisor

Shell Script needed...for user account details

Hi,

I need to write a run a script on Redhat Linux Server which must provide the following output.

1. What all users accounts are there in the Linux OS.
2. What all groups each user account belongs.
3. When did they last login!!

I am new bie in shell scripting..need your help on this...

Thanks
Girish
5 REPLIES 5
Ivan Krastev
Honored Contributor

Re: Shell Script needed...for user account details

Here is some :

#!/bin/sh

for i in $(awk -F: '$3 > 100 { print $1 }' /etc/passwd ); do
echo User: $i " " Groups: groups $i
echo LastLogin: `last $i | head -1`
done




regards,
ivan
Alpha977
Valued Contributor

Re: Shell Script needed...for user account details

Hello Girish
i think you don't need a script.

You can launch 2 command:

"who" and "finger"

If you need a script to have a "report", the previous answear is good.

Bye!
girishb
Frequent Advisor

Re: Shell Script needed...for user account details

Thanks buddies for great responses... :)

Gary Cantwell
Honored Contributor

Re: Shell Script needed...for user account details

Hi Girish,

Please take a moment to assign points to those who have take the time to assist you, here's how:

http://forums1.itrc.hp.com/service/forums/bizsupport/helptips.do?#33

Thanks,

Gary
George Liu_4
Trusted Contributor

Re: Shell Script needed...for user account details

If you are using NIS or LDAP, you may have different methods/commands.