Bash script as root problem
Karl Auer
kauer at biplane.com.au
Sat Mar 16 22:38:39 UTC 2013
On Sat, 2013-03-16 at 22:32 +0100, Johnny Rosenberg wrote:
> I have a bash script that I am going to run as root (sudo
> script_name), but in that script there is a line that I want to be
> executed as a regular user. Is that possible or do I need to do it the
> other way around, that is enter sudo at the beginning of every line
> except the one that I need to be run as a user?
If the script will be running as root, you cam use the -u option to sudo
to run any command as any user, without a password. see "man sudo".
So just write your script, and use sudo to run the single command that
must be run as a particular user.
Warning: I have not tested the above answer. Test, and test with care.
Regards, K.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)
http://www.biplane.com.au/kauer
http://www.biplane.com.au/blog
GPG fingerprint: B862 FB15 FE96 4961 BC62 1A40 6239 1208 9865 5F9A
Old fingerprint: AE1D 4868 6420 AD9A A698 5251 1699 7B78 4EEE 6017
More information about the ubuntu-users
mailing list