5

When I type in my console "runuser", I am getting "command not found". I though this command was pretty standard, but I cannot find it on my system.

I am on the root user but I do not have the password of the other user.

user37220
  • 225
  • 2
  • 5
  • 8
  • Please justify when you click on "-1" on a question. Thank you. – user37220 Jun 26 '13 at 12:57
  • 1
    I didn't downvote this (yet), but if you mouse over the down arrowhead, it says "this question does not show any research effort; it is unclear or not useful". If a downvote appears without further comment, you may reasonably assume that that's what the voter thought of your question. – MadHatter Jun 26 '13 at 12:59
  • 1
    `runuser` is intended for use by system services which need to [change UID and preserve their SELinux security contexts](http://danwalsh.livejournal.com/55588.html). This is not a command that you should be running yourself. – Michael Hampton Jun 26 '13 at 14:51

3 Answers3

6

On Ubuntu you have su and sudo for this sort of thing:

su - username

Changes to user username, as if that user had logged in.

sudo -u username command

Run a single command as user username.

l0b0
  • 1,140
  • 1
  • 8
  • 17
  • 3
    Thanks. However, I am looking for the runuser function because I do not have the password for the other user. – user37220 Jun 26 '13 at 12:56
  • You don't need the password if you set up `sudoers`. – l0b0 Jun 26 '13 at 12:57
  • When I do "su - otheruser", I am getting "No directory, logging in with HOME=/". Then when I run "whoami", I get "root". – user37220 Jun 26 '13 at 13:00
  • `No directory, logging in with HOME=/` is normal if the user has no home directory assigned or the directory doesn't exist. How you get `root` from `whoami` is beyond me. – l0b0 Jun 26 '13 at 13:03
  • Yes, the error message is normal. It is the whoami which I do not understand. – user37220 Jun 26 '13 at 13:11
4

From your comment on the other answer:

When I do su - otheruser, I am getting No directory, logging in with HOME=/. Then when I run whoami, I get root.

This happens because 'otheruser' hasn't got a shell (like bash). It's probably something like /bin/false. If you want a shell as 'otheruser', use this instead:

sudo -u otheruser /bin/bash
ThatGraemeGuy
  • 15,473
  • 12
  • 53
  • 79
0

It is in the util-linux package, so if you want it, install that package.

reinierpost
  • 412
  • 3
  • 9