Score:0

Linux folder permissions

in flag

I am new to linux and trying to setup permissions on a folder. But it is not working as expected.

I have a folder: /mnt/vpstorage The permissions given for this folder are: 0750 If I understand correctly, it means: owner has rwx, group has rx and others do not have any permission.

The group for this folder is: "storageusers" and I am member of this group. So it means, I have rx permissions on the folder /mnt/vpstorage/.

I am trying to list the contents of the folder using below command:

ls -l /mnt/vpstorage/

But I am getting the error

ls: cannot open directory '/mnt/vpstorage': Permission denied

If I am member of the group which has rx permissions on a folder, why can't I list the contents of that folder?

Please advise.

Thanks.

Nmath avatar
ng flag
It's usually a mistake to change the permissions to begin with, especially if you don't know what you're doing. Since this is a mounted volume, if you want to be able to read, use `sudo chmod -R 755 /mnt/vpstorage/`. Don't do this for anything else, especially your root file system, or you will break your system. Make sure you don't accidentally hit enter after the first `/` or you will damage your system unrecoverably. In the future, leave permissions alone
Keval Shah avatar
nu flag
Just use **sudo** that is ***sudo chmod -R 755 /mnt/vpstorage/***
Vikram avatar
in flag
@Nmath Thanks for the explanation. But can you please elaborate? I do not want anyone except the members of storageusers group to access the files/folders in /mnt/vpstorage folder. That is why I set the permissions as 750. If I set the permissions as 755, then all users will get read+execute, which I do not want. Could you please explain how this can be achieved? Thanks.
waltinator avatar
it flag
Explore your permission/ownership problems with `https://github.com/waltinator/pathlld`. A `bash` script to answer "Why can't I Read/Write that file?".
Vikram avatar
in flag
@KevalShah If I set permissions to 755, will all users be able to access the contents of the folder? I want only members of "storageusers" group to access the folder /mnt/vpstorage.
Nmath avatar
ng flag
Because there are more users in your system that are used by applications and processes. If you want a volume in your system that you don't want others to be able to access you can use an encrypted container
cc flag
If what you say about group membership is correct, you should have been able to read the dir. How did you "join" the group? Remember, editing /etc/group is not sufficient, there is a gshadow file too.
Vikram avatar
in flag
@ubfan1 never mind. I re-added myself to the storageusers group and now everything is working as expected. I am not sure why it did not work before. May be I need to logout and log back in for system to identify me as member of the group?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.