I have a folder which has a lock emblem on it. When I try to delete the folder, I get a Permission Denied
error message.
2 Answers
That lock icon means that you do not have the permission to edit that folder or write anything inside of it.
The reason of this, might be several things.
You are not the owner of that folder. If this is a multi-user desktop, it could belong to some other user, or to the root user. Check the ownership in
right click to the folder> Properties> Permissions
.The folder could be read-only. On Linux, folders have 3 bits of permissions, read, write, execute. If the write bit is not set to 1 (True), you are not allowed to edit or write inside that folder. Check the properties in
right click to the folder> Properties> Permissions
.
If you are the owner of this folder, you can change the permissions to allow writing in to that folder from the same place that you have checked.
If you are not the owner of this folder, and if this is a multi-user setup, ask the owner to have the permission to write. If this is a single user setup, run this command on a terminal to change the ownership of the file (substitute username
with your username):
sudo chown username:username /path/to/that/folder
-
thanks for your response, the owner of the folder was root. I have managed to delete the folder using sudo rm command Sep 27, 2022 at 5:34
It’s very likely that you don’t have the required permissions to write to that folder.
check that you really do want to delete this folder … Ubuntu will often warn you if you’re trying to do something dangerous - the lock symbol might be that warning!
try right-clicking on the folder, select the permissions tab and change the permissions for ‘me’ to ‘Create and delete files’ if that option is available
if that option’s not available, you’ll need to change permissions from the command line:
find the path to that folder: easiest way is to right-click on the folder, under the ‘Basic’ tab in Properties, you’ll see the ‘Parent folder’.
Highlight the parent folder, then open a terminal (Ctrl-Alt-T), and type
sudo chmod 777 path-to-folder
(You’ll have to add the folder name at the end of the Parent folder you obtained above).
That changes permissions for everyone to read / write / execute the folder. You should be able to delete the folder now.
if you’re not the owner of the folder you’ll need to change that: In the terminal again, make yourself the owner of that folder:
sudo chown -R username path-to-folder
Just be sure to double-check you really want to be able to delete / modify this folder … whenever using sudo, pause before hitting enter - the requirement to use elevated privileges is more to protect you from damaging your system than a security feature
-
thanks for your response, the owner of the folder was root.I have managed to delete the folder using sudo rm command Sep 27, 2022 at 6:01
-
Glad you sorted it ... you should probably check why the owner was root - likely nothing to worry about but if you can see why it happened you can prevent it happening again.– WillSep 27, 2022 at 8:59
-
yeah, I figured it out. It was actually a rar file but when I used unrar to extract it I used sudo by mistake which give the folder root permission. Sep 27, 2022 at 15:40
ls -ld path/to/dir
, once you have found the directory,sudo rm -rf /path/to/dir
. Be careful!sudo rm -rf
is a Very Dangerous command. If you get it wrong you can destroy your system. Is the underlying filesystem is mounted Read-Only? Explore your Mount/Read/Write/Execute problems withhttps://github.com/waltinator/pathlld
, abash
script to show the permissions, mount options along the path to an object or objects.