Shadow file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shadow file
# 1  
Old 04-15-2009
Shadow file

Hi,

In shadow file

smithj:Ep6mckrOLChF.:10063:0:99999:7:::
3rd Field 10063 indicates the number of days (since January 1, 1970) since the password was last changed.

I want to get the result with script the date on which the password was last changed in YYYY-MM-DD format.

can someone please help
# 2  
Old 04-15-2009
Sorry I dont know well bash script and sed :P but i think you can start from this:

$ chage --list [user] | sed -e '1!d' -e 's/^.*\: //'

change [user] with a true user and you can make a script that extract all users and a while loop for exec command for any user and another loop for change output in YYYY-MM-DD format.
.
I dont know if this is the better solution but I hope someone can help you better Smilie

bye Smilie

Last edited by aspire; 04-16-2009 at 12:11 AM..
# 3  
Old 04-16-2009
not knowing your OS:

solaris: passwd -s smithj
linux: passwd -S smithj
aix: perl -e 'print scalar(localtime( `lsuser -a lastupdate smithj` ))'

use printf to format to your liking
# 4  
Old 04-16-2009
Quote:
Originally Posted by aspire
Sorry I dont know well bash script and sed :P but i think you can start from this:

$ chage --list [user] | sed -e '1!d' -e 's/^.*\: //'

change [user] with a true user and you can make a script that extract all users and a while loop for exec command for any user and another loop for change output in YYYY-MM-DD format.
.
I dont know if this is the better solution but I hope someone can help you better Smilie

bye Smilie
smithj:Ep6mckrOLChF.:10063:0:99999:7:::

I think there is some misunderstanding.
I want to convert 10063 i.e 3rd field in shadow file from days format to date format of YYYY-MM-DD

Suppose the 3rd field is 365 then this should be converted to 12-31-1970
because 3rd Field indicates the number of days (since January 1, 1970)
# 5  
Old 04-16-2009
like this?

$ date -d @1
output:
Thu Jan 1 01:00:01 CET 1970
You must convert days in seconds i think...

(Sorry...I dont know if there is a better solution :P )

Last edited by aspire; 04-16-2009 at 01:01 AM..
# 6  
Old 04-16-2009
Quote:
Originally Posted by aspire
like this?

$ date -d @1
output:
Thu Jan 1 01:00:01 CET 1970
You must convert days in seconds i think...

(Sorry...I dont know if there is a better solution :P )

Can any expert please reply to this.

Appreciate it
# 7  
Old 04-16-2009
Quote:
Originally Posted by zenith
smithj:Ep6mckrOLChF.:10063:0:99999:7:::

I think there is some misunderstanding.
I want to convert 10063 i.e 3rd field in shadow file from days format to date format of YYYY-MM-DD

Suppose the 3rd field is 365 then this should be converted to 12-31-1970
because 3rd Field indicates the number of days (since January 1, 1970)

Can someone help me how to do this using ksh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shadow file help

As a part of linux hardening In shadow file all Application accounts which are not locked must contain only an asterisk “*” in the Passwd field. But how would i do it by using command? Is there any way other than modifying shadow file to accomplish this task? (3 Replies)
Discussion started by: pinga123
3 Replies

2. Solaris

Solaris :regarding /etc/shadow file

what does the last column in /etc/shadow file indicate?? i read man page,it tells its FLAG..but i am not able to understand exactly why its there :confused: thanks in advance, shekhar (4 Replies)
Discussion started by: shekhar_4_u
4 Replies

3. UNIX for Dummies Questions & Answers

How Do I Regenerate the Shadow file

I guess the earlier problem I had with changing user passwords and creating new users is related to the shadow file. Anytime I change something to /etc/passwd or shadow I get locked out. HOW DO I REGENERATE THIS FILE. (1 Reply)
Discussion started by: Waitstejo
1 Replies

4. Shell Programming and Scripting

appending LK to the shadow file

Hey guys.. i need to be able to append 'LK' to a password field in the shadow file I cannot use commands such as usermod chsh i need to directly be able to manupilate the files through a menu driven interface. So in other words write to the shadow file How could i do this? so far... (1 Reply)
Discussion started by: musicmancanora
1 Replies

5. UNIX for Dummies Questions & Answers

Shadow File

I see conflicting definitions for the shadow file. For Solaris, what are the fields please? Thanks. (3 Replies)
Discussion started by: DavidS
3 Replies

6. UNIX for Advanced & Expert Users

/etc/shadow file....

Does anyone know what "!!" represents in the password field of the /etc/shadow file? :confused: (6 Replies)
Discussion started by: avcert1998
6 Replies

7. Solaris

*LK* in /etc/shadow file

my etc/shadow file showing *LK* for a particular user.. can u tell me under which circumstances a user is locked (5 Replies)
Discussion started by: vikashtulsiyan
5 Replies

8. UNIX for Advanced & Expert Users

shadow file

what does 'x' in the encrypted password field in /etc/shaodw file represent? (3 Replies)
Discussion started by: jbashir
3 Replies

9. Programming

Doubt on shadow file

Hi guys, I have a doubt on shadow file ... In the Unix servers in which I am working, I cud see that the shadow file has only one permission set .. tht is read permission for only root user ... (-r--------) .... So my basic doubt here is that how this file is being written then ... only... (4 Replies)
Discussion started by: Sabari Nath S
4 Replies

10. UNIX for Dummies Questions & Answers

shadow file

Sirs, What is a shadow file,How it be usefull.For my project i have to keep the password in shawdow file also i am doing in php how can i do it. Thanks in advance, ArunKumar (3 Replies)
Discussion started by: arunkumar_mca
3 Replies
Login or Register to Ask a Question