0

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.

folder which has a "lock" icon

2
  • You should not put everything in the question title. It should summarize it, not fully explain it.
    – Emre Talha
    Sep 27, 2022 at 5:17
  • 1
    Check the dir's properties through the right-click menu, and it's parent's properties. You need write access to the parent directory to delete it. Or, open a terminal, 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 with https://github.com/waltinator/pathlld, a bash script to show the permissions, mount options along the path to an object or objects.
    – waltinator
    Sep 27, 2022 at 5:34

2 Answers 2

0

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.

  1. 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.

  2. 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
1
  • 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
0

It’s very likely that you don’t have the required permissions to write to that folder.

  1. 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!

  2. 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

  3. 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.

  4. 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

3
  • 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.
    – Will
    Sep 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

You must log in to answer this question.

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