On Wed, Jun 19, 2013 at 8:17 PM, Anthony <lists(a)cajuntechie.org> wrote:
Hello Everyone,
How do I add myself as co-owner of a directory? I set up a new apache
server and need to transfer files to /var/www/html. The problem is, of
course, I've denied root login but don't have sufficient privs to
login and transfer files under my username.
How can I fix this?
There are a few ways to go about this. There are lots of ways to
control access to files and directories on Linux systems. ;-)
You could create a group with permissions to edit the directory, and
add yourself to it:
# create an 'htmleditors' group
groupadd htmleditors
# add 'anthony' to it
usermod -aG htmleditors anthony
# change the directory to be owned by the group
chgrp -R htmleditors /var/www/html
# grant read/write permissions to the group
chmod -R g+rw /var/www/html
Or you can use POSIX ACLs to just give yourself access:
# give 'anthony' Read/Write/eXecute permissions on all files in /var/www/html
setfacl -R -m u:anthony:rwX /var/www/html
# do the same for directories
find /var/www/html -type d | xargs setfacl -R -m d:u:anthony:rwX
You can even combine the two:
groupadd htmleditors
usermod -aG htmleditors anthony
setfacl -R -m g:htmleditors:rwX /var/www/html
find /var/www/html -type d | xargs setfacl -R -m d:g:htmleditors:rwX
See the man pages for the various commands used for more information
about what exactly is going on.
-T.C.