Using chown in a script



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

--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users



Relevant Pages

  • Re: Using chown in a script
    ... the script that requires root privileges). ... I didn't find an environment variable for the groups I belong to, ... Johnny Rosenberg ... Tried with a simple script and found that all three of them was "root" ...
    (Ubuntu)
  • Re: deny all logins except for two specific accounts
    ... Here's a quick script I wrote to do just what you are talking about. ... the username, a filename with valid users and a 'message' file. ... >> everyone but root from logging on. ... >> to allow the primary account for my informix database to login as well ...
    (comp.unix.aix)
  • Re: Net::SCP::Expect problem
    ... to get the progress meter to function whitin net::scp::expect? ... > If I run this script as root the scripts try to connect as root, ... > as the user Ive set in $username. ...
    (comp.lang.perl.misc)
  • Net::SCP::Expect problem
    ... If I run this script as root the scripts try to connect as root, ... as the user Ive set in $username. ... Regards, ...
    (comp.lang.perl.misc)
  • IBM Informix Web DataBlade: Local root by design
    ... IBM Informix Web DataBlade: Local root by design ... Impact: Any user who can: 1) Save a Perl script anywhere on the server's ... admin right on any database can do it by loading the WDB module into ...
    (Bugtraq)