PDA

View Full Version : sudo -u #uid



chandra
August 6th, 2007, 09:27 AM
Folks,

I wish to invoke sudo with the -u option and want to use the UID rather than the username. The man page says (among other things):

sudo [-u username|#uid]

However, when I invoke sudo with, say UID 1000, as:

sudo -u 1000 <some command>

I get

sudo: no passwd entry for 1000!

If I try

sudo -u #1000 <some command>

I only get the help text.

Can anyone shed some light on this behaviour and help out, please?

Thank you.

nitro_n2o
August 6th, 2007, 11:33 AM
you need to add youself to /etc/sudoers to edit the file

sudo visudo
unfortunately I don't know what should u enter in that file exactly

kpatz
August 6th, 2007, 01:45 PM
Folks,

I wish to invoke sudo with the -u option and want to use the UID rather than the username. The man page says (among other things):

sudo [-u username|#uid]

However, when I invoke sudo with, say UID 1000, as:

sudo -u 1000 <some command>

I get

sudo: no passwd entry for 1000!

If I try

sudo -u #1000 <some command>

I only get the help text.

Can anyone shed some light on this behaviour and help out, please?

Thank you.The shell treats # as a comment delimiter, so you'll need to escape it or put it inside quotes.

Any of these will work:

sudo -u \#1000 <some command>
sudo -u '#1000' <some command>
sudo -u "#1000" <some command>

chandra
August 20th, 2007, 02:12 AM
The shell treats # as a comment delimiter, so you'll need to escape it or put it inside quotes.

Any of these will work:

sudo -u \#1000 <some command>
sudo -u '#1000' <some command>
sudo -u "#1000" <some command>

Thanks. That did the trick :-)