|
FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
is this possible
Is it possible when logged in as root to run command as user, bit like sudo in reverse?
cheers |
|
||||
su(1) will work when logged in as root; otherwise the password for the "run as" user is required.
Using sudo, any user can be permitted to "run as" another, without needing that userid's password. In addition, one can "run as" another user that does not have a usable $HOME or login shell. |
|
|||
Hello and thanks for replies.
the su method seemed to fail Code:
su - wwwuser -c touch /hsphere/local/home/wwwuser/test.txt The parent process is not sshd. Exiting... but sudo method worked for touch Code:
sudo -u wwwuser touch /hsphere/local/home/wwwuser/test.txt Did not work for script app.sh but think that maybe another issue i looking into. cheers |
|
||||
re: su
On OpenBSD, the -c option is for login class, not for command. See the su(1) man page. Here's an example of substituting the identity of a typical "nologin" userid: Code:
# su -m nobody ksh: Cannot determine current working directory $ touch /tmp/test $ exit # ls -l /tmp/test -rw-r--r-- 1 nobody wheel 0 Feb 18 13:05 /tmp/test |
|
||||
Ooops. This is FreeBSD. Sorry. But -c is still login class. See the FreeBSD version of su(1).
|
|
||||
See the examples in that same manual ..
Code:
EXAMPLES su -m man -c catman Runs the command catman as user man. You will be asked for man's password unless your real UID is 0. Note that the -m option is required since user ``man'' does not have a valid shell by default. su -m man -c 'catman /usr/share/man /usr/local/man' Same as above, but the target command consists of more than a sin- gle word and hence is quoted for use with the -c option being passed to the shell. (Most shells expect the argument to -c to be a single word). Code:
su -m www ps /bin/ps: /bin/ps: cannot execute binary file su -m www -c ps PID TT STAT TIME COMMAND 1023 p0 R+ 0:00.00 ps Last edited by DutchDaemon; 18th February 2009 at 09:05 PM. |
|
|