Wednesday, February 17, 2016

linux - Can't access a directory even with full permissions and ownership?



I'm running into a weird issue. I have a directory, let's call it dir, which I (user) want to access. Having tried a few permission setups I can't get it to work, so I went to the extreme: change owner recursively to user:user, set permissions to 777. ls -hal now reports: lrwxrwxrwx 1 user user 94 Nov 16 10:35 dir.
Yet, when I try cd dir I get -bash: cd: dir: Permission denied. The only way to access the folder seems to be to first sudo su, but I want to be able to give access to other users without sudo privileges, and it would be nice to be able to use the directory myself without using sudo powers.




What can I do to get into the directory?



EDIT: I accidentally did the ls -hal in the wrong directory so it shows dir as a symlink, but the actual directory dir links to has the exact same permissions, and I can't get into it the 'normal' (just use absolute path instead of symlink) way either. However, weirdly I can't even ls -hal in the parent dir of the directory I want to access: ls: cannot open directory '.': Permission denied



EDIT: Apparently I just needed to log out and in again and everything worked. I guess ownership doesn't immediatly change when logged in?


Answer



If you are working over SSH, logging out and in again fixes the problem.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...