Create summery of al users + date

Hello,

I have problem to write script which can collect users "username" and the time that each user has been created in our machine and store these data in file database.txt

I have searched a lot and found we can see the exact time we create user with: passwd -S username also list user will do with ls

How can I have database data with this sample template?
database.txt :

username1 > 2014 02 12
username2 > 2014 02 10

I'm a bit confused as to what you are asking here nimafire.

The output from passwd -S will show you the date that the password was changed most recently, not the creation date. I'm not aware of a way to list creation date. You don't give us your OS or version, so it's a bit difficult to be sure.

I'm not clear what you wish to achieve with a simple ls command.

Can you show us what you have tried to put together so far and perhaps we can steer you around where you are getting stuck.

Please post code, files, input & output/errors in CODE tags so that the are clear to read.

Thanks, in advance,
Robin

im using redhat OS - Centos,
i have create tem username so the password modification time of user is as same as the time that it has created in my machine ,
i want to list all user + create time when run script
sh date

Okay, I think I have it.

Red Hat is not CentOS. They are very closely related though.

Assuming that none of your users have logged on and chosen a new password yet, you could do the following:-

  • Using /etc/passwd, loop for each user
    [list]
  • Display a line for that user and the output from passwd -S
    [/list]
  • Repeat for next user

You can get a list of users by using:-

cut -f1 -d":" /etc/passwd    # First field with delimeter :

Put this in a loop and run the display statement for the details you want.

Does that help?

Robin