0

I am trying to change user monitor uid in /etc/passwd , but below gives me an error:

sed -s /etc/passwd <<-"EOF" /^\(monitor:[^:]*:\)[0-9]*:[0-9]*:/s//\10:0:/ w q EOF 
8
  • 7
    ... This sounds like a tremendously bad idea if you accidentally succeed. What are you actually trying to accomplish? Commented Oct 10, 2017 at 14:11
  • 3
    Use usermod -u. That's what it is there for Commented Oct 10, 2017 at 14:13
  • 6
    You're confusing sed with ed Commented Oct 10, 2017 at 14:15
  • 4
    Why do you "need" to change userid to 0? I bet if you explained the problem you are really trying to solve, somebody would come up with a better idea of how to solve it. Commented Oct 10, 2017 at 14:19
  • 2
    How have you added the user to the admin group? With groupmod? Commented Oct 10, 2017 at 14:43

1 Answer 1

1

If for some reason usermod -u can not be used:

sed -i -e 's/^\(monitor:[^:]\):[0-9]*:[0-9]*:/\1:0:0:/' /etc/passwd 

Please note it is /\1:0 not /\10: as this would be parameter 10.

But having monitor to have uid 0 might not be a good idea at all.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.