7

How to delete locked folders/files? When I try to delete them an error occurs: "Error removing file: Permission denied" I am root. See the image below to know what kind of folders/files.

enter image description here

thanks

5
  • Did you launch your file explorer as root?
    – Henry
    Mar 23, 2015 at 20:18
  • I am sorry, I have no idea what you are talking about, I'm new...
    – Leonardo
    Mar 23, 2015 at 20:18
  • Try going to the terminal at typing in "sudo nautilus", then press enter. Type your password when prompted, this will open the file explorer (nautilus) and give it root permissions
    – Henry
    Mar 23, 2015 at 20:20
  • Sorry, but if you're new, then are you sure you really need to delete these?
    – user300458
    Mar 23, 2015 at 20:24
  • @ user300458 - yes, I am sure. @ Henry - I will try thanks
    – Leonardo
    Mar 23, 2015 at 20:25

5 Answers 5

8

Launch your file explorer as root using:

gksudo nautilus

This will open your file explorer, and grant it root, so it should be able to view/delete the directory/file.

If you are like me, and don't care about the warnings in this question you can use this instead:

sudo nautilus
7
  • gksudo nautilus (not sudo)
    – user300458
    Mar 23, 2015 at 20:22
  • sudo works as well, I never understood why people used gksudo, it always caused my more trouble because I needed to install it, as it was not included with my system. And I find it more annoying to have to wait for the window to open, then type in my password, possibly blocking other open windows. I prefer if it just asked for my password in the terminal, it's quicker and less obstructive.
    – Henry
    Mar 23, 2015 at 20:23
  • askubuntu.com/q/11760/300458
    – user300458
    Mar 23, 2015 at 20:25
  • Edited my answered to include both sudo and gksudo
    – Henry
    Mar 23, 2015 at 20:32
  • IT WORKED ONLY WITH GKSUDO
    – Leonardo
    Mar 23, 2015 at 20:58
8

Try the following: launch Terminal and enter

sudo rm -rf '/path/to/locked/folder'

And be VERY careful with the path to folder!

4

Steps:

  1. Open Terminal.
  2. Run command:

    sudo su
    
  3. Command above would ask for your password.
  4. Once the correct password is given, you would give following command.

    chmod a+rwx folder/file 
    

    and go to home and just delete the folder/file.

  5. Exit for root user type exit.

4
  • @Zanna: sudo su works on my system and I didn't change the root account or the sudoers configuration in a relevant way. But it's unnecessary because one could just run sudo chmod ... instead. Oct 25, 2016 at 10:02
  • @DavidFoerster I thought I had deleted that comment already! but yes indeed it's completely unnecessary
    – Zanna
    Oct 25, 2016 at 10:03
  • 1
    This answer is basically the same as kos' but with less detail and worse practices. Oct 25, 2016 at 10:04
  • yeah agree with that too
    – Zanna
    Oct 25, 2016 at 10:04
2

The lock symbol means your user currently have no write permission on the file/folder. To change this:

  1. Check the current owner/group/permissions status by right clicking the file/folder, clicking Properties and then switching to the Permissions tab.
  2. Open a Terminal by hitting Ctrl+Alt+t.
    • If you are the Owner of the file (i.e. the Owner field shows your username): add write permission to the owner by running this command: chmod u+w <path_to_file_folder>
    • If you are not the Owner of the file, but you are in the Group group (i.e. the Group field shows your username or a name of a group to which you belong, e.g. sudo): add write permission to the group by running this command: sudo chmod g+w <path_to_file_folder>
    • If you are not the Owner of the file and you are not in the Group group: add write permission to the others by running this command: sudo chmod o+w <path_to_file_folder>
  3. Run exit

And then just delete the file/folder from Nautilus.

Alternatively:

  1. Open a Terminal by hitting Ctrl+Alt+t.
    • Remove the file/folder as root by running this command: sudo rm -rf <path_to_file_folder>
1

Here is something , that I found was easier to do instead of opening terminal. Right-Click the file and open properties. Then switch to the permissions tab. Then wherever it says Access: change it from whatever it is to Create And Delete Files. This should remove the lock and then you can delete the file normally.

You must log in to answer this question.

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