Using chown in a script
Gurus Knugum
gurus.knugum at gmail.com
Sun Sep 5 15:02:39 UTC 2010
I copy some files in a script that I run as root (there are other things
in the script that requires root privileges). So the copy of the file now
belongs to root, but I want it to belong to the user, so I figured
something like this:
cp /a/system/file /a/place/in/my/home/directory/
chown -R <Some user>:<Some Group> /a/place/in/my/home/directory/
Running the env command I noticed my username three times:
$USER
$USERNAME
$LOGNAME
Which one should I use for <Some user> above?
For example:
chown -R ${USERNAME}:${USERNAME} /a/place/in/my/home/directory/
I didn't find an environment variable for the groups I belong to, so I
guess I can use the same as for owner, right?
--
Kind regards
Johnny Rosenberg
More information about the ubuntu-users
mailing list