Unix/Linux Forum: modify /etc/shadow - Unix/Linux Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

modify /etc/shadow Rate Topic: -----

#1 User is offline   tjay83 

  • User Level: 1/10
  • Pip
  • Group: Members
  • Posts: 18
  • Joined: 11-August 08

Posted 16 September 2008 - 01:28 AM

Hi

I am looking for script to modify /etc/shadow.

For example:
1-)User enters username
2-)The line of that user is found in /etc/shadow and *LK* is added infront of the second field in /etc/shadow.

How can I do this?

Thanks
0

#2 User is offline   eggi 

  • User Level: 6/10
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 311
  • Joined: 25-November 07
  • Location:Grayslake, IL USA

Posted 17 September 2008 - 03:41 AM

Hey There,

This is answered in one other post, also, just use the second version and set the username variable in your shell script:

but, of course, be careful :)

$username=user123
awk -F":" -v user="$username" '{ if ( $0 ~ /user/ ) print $1 ":*LK*" $2 ":" $3 ":" $4 ":" $5 ":" $6 ":" $7 ":" $8 ":" $9}' /etc/shadow


to get user123 using the -v switch to set the username variable in the shell and transmute it to the awk variable "user"

Hope that helps :)

, Mike
The greatest viral marketing idea of all time, get your copy of this Free Report now!
----
Linux Tips, Trick and Advice -- The Linux and Unix Menagerie
0

#3 User is offline   tjay83 

  • User Level: 1/10
  • Pip
  • Group: Members
  • Posts: 18
  • Joined: 11-August 08

Posted 17 September 2008 - 03:46 AM

thanks eggy
0

#4 User is offline   eggi 

  • User Level: 6/10
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 311
  • Joined: 25-November 07
  • Location:Grayslake, IL USA

Posted 18 September 2008 - 02:22 AM

No problem. Happy to help :)

Seriously, though - be careful. One mistake and it could mean disaster. Actually, just back up the old one and you should be good (So simple it always evades me until the last second ;)

, Mike
The greatest viral marketing idea of all time, get your copy of this Free Report now!
----
Linux Tips, Trick and Advice -- The Linux and Unix Menagerie
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users