How to make directory writable to myself in Linux?

I have directory

drwxr-xr-x 20 root root 4096 Aug 11 17:05 webapps

now I want to allow myself (dims) to write to this directory.

bash-3.2$ groups dims
dims : web2 users

How to accomplish this? Should I add myself to group "root"? Or may be I should change group ownership to a directory?

I don't want to compromise access and make dims root equivalent.

1

3 Answers

You can change the group owner of the folder to 'wheel' like so:

# chgrp wheel -R webapp

Then add yourself (dims) to the 'wheel' group like so:

# vi /etc/groups` // (or whichever editor you prefer)
...
`wheel:x:10:root,dims` //(edit this line. It may defer on your system. just add (dims) to that line
...

and save. Make sure the group has write permissions on the folder like so:

# chmod g+w -R webapp

1) chmod 777 webapps

Then every one can read, write and execute – a dangerous way but not for your local directories.

2) chown dims:dims webapps

Now this directory is yours, and you can play with it, changing permissions for instance.

5

In my opinion, the best way to achieve this is to use ACL (Access Control List), depending on your distribution, this will be enabled by default, if this is not the case, you should follow the instructions on your distribution wiki/help.

Then, once your partition is mounted with ACL option you can use the following to add write permission:

setfacl -m u:dims:rwx webapps
setfacl -m d:u:dims:rwx webapps

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like