'"ls" permission denied even though I have read access to the directory [closed]
Although I am the owner (pi) of the directory, still permission is denied
pi@raspberrypi:~/Desktop $ sudo ls -al
total 16
d-wx--x--x 3 pi pi 4096 Jan 12 11:30 .
drwxr-xr-x 21 pi pi 4096 Jan 12 11:28 ..
-rw-r--r-- 1 pi pi 82 Jan 11 16:13 cmd.txt
drwxr-xr-x 6 pi pi 4096 Jan 12 11:30 openvibe-2.0.0-src
pi@raspberrypi:~/Desktop $ ls
ls: cannot open directory '.': Permission denied
Solution 1:[1]
As you can see in the output of your command, your directory has incorrectly set permissions.
Permissions on directories
Files and directories both have read, write and execute permissions, but they mean different things. For directories, the permissions have the following meanings:
r
(read) - When present, the content of the directory may be read.w
(write) - When present, the content of the directory may be changed. This means files can be created, renamed and deleted. This requires thex
flag to also be set.x
(execute) - When present, the directory can be set as the current working directory viacd
.
More information can be seen here.
How to fix the problem
The default permissions when creating a new directory on most Linux distributions is drwxrwxr-x
, which means the owner and group both have permission to read and modify the contents of the directory, as well as cd
ing into it. Any other users may read the contents, but not add any new files.
To do this, you need to execute chmod 0775 ~/Desktop
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | MechMK1 |