4

I am a new Ubuntu user. Previously I used Windows. I am facing permission issues in every steps. Actually I am looking for file and folder permission like windows. I read several documents regarding this but I could not be clear.

Like,I would like to get all types of permission for this directory /opt/lampp/htdocs and sub directories.

I tried following command

sudo chown -R abu:abu /opt/lampp/htdocs

But nothing happend.

Can anyone help me in this regard ??

5
  • How is it not working? Errors or...?
    – Nephente
    Oct 3, 2015 at 12:50
  • How is it failing? What exactly do you want to do? Change the permissions of all files? All files and directories? What happens when you run the commands? Please edit your question and clarify.
    – terdon
    Oct 3, 2015 at 12:50
  • Please explain what you are actually trying to do. The command you show will set the permissions of the directory /opt/lampp/htdocs to drwxr-xr-x, is that what you wanted?
    – terdon
    Oct 3, 2015 at 13:15
  • @terdon thanks for your reply. I want to set READ,WRITE and EXECUTION permission recursively to /opt/lampp/htdocs.
    – abu abu
    Oct 3, 2015 at 13:27
  • In Linux the rule "if there is no need for a command to show output it should not show output" applies. You may assume: no text means it got executed The results for this command are checked with the ls -l or the tree command.
    – Rinzwind
    Oct 5, 2015 at 8:19

2 Answers 2

7

The command won't output anything at all if it worked unless you add the V option to make it produce output verbosley. I recomend you read the chmod manual available here or by running man chmod as you should make sure you know what each command is doing.

To make it work recursivly, you just need to pass the -R recursive flag - e.g. so this command will make everything in /opt/lampp/htdocs have the permission -rwxr-xr-x (file folder owner can read. write and execute, the group and everyone else can read and execute :

sudo chmod -R 755 /opt/lampp/htdocs

Please note that this I think will apply to both files and directories, and if directories do not have a executable permission they won't work (see here). So if you don't want files to be excutable, you will need to use something like this (probably as root):

find /path/to/base/dir -type d -exec chmod 755 {} +
find /path/to/base/dir -type f -exec chmod 644 {} +

If you want to know what this does, you can read the relevant parts of the find manual (man find). Basically if find all the files/folders in the specified path and changes the permissions of them.

If you want to become the owner (and group) of the files (may not recommendable for server and system configuration files) so you can change (write to) them, consult this question. This is also possible by being in a group that has write access to the files, or by making all 'other' users have write access to them

1

You're not seeing anything because none of those commands is meant to output anything, but that doesn't mean that the changes weren't made;

To get a visible feedback of the changes you made you may just run ls -l on each affected directory to check its content, however a neater way to do this would be to install tree and to use it to list each directory / file along with the desired attribute(s) recursively:

tree -u -g -p
  • -u: lists directories / files along with the owner
  • -g: lists directories / files along with the group
  • -p: lists directories / files along with the permissions
user@user-X550CL ~/tmp % tree -u -g -p
.
└── [drwxrwxr-x user     user    ]  dir
    ├── [-rw-rw-r-- user     user    ]  file1
    ├── [-rw-rw-r-- user     user    ]  file2
    ├── [-rw-rw-r-- user     user    ]  file3
    ├── [drwxrwxr-x user     user    ]  subdir1
    ├── [drwxrwxr-x user     user    ]  subdir2
    └── [drwxrwxr-x user     user    ]  subdir3

4 directories, 3 files
user@user-X550CL ~/tmp % find . -type d -exec chmod 755 {} \;
user@user-X550CL ~/tmp % find . -type f -exec chmod 644 {} \;
user@user-X550CL ~/tmp % tree -u -g -p                       
.
└── [drwxr-xr-x user     user    ]  dir
    ├── [-rw-r--r-- user     user    ]  file1
    ├── [-rw-r--r-- user     user    ]  file2
    ├── [-rw-r--r-- user     user    ]  file3
    ├── [drwxr-xr-x user     user    ]  subdir1
    ├── [drwxr-xr-x user     user    ]  subdir2
    └── [drwxr-xr-x user     user    ]  subdir3

4 directories, 3 files

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .