0

I'm new to Ubuntu and I'm trying to delete some of my files but I get a message saying "Permission denied", and my files are locked. How do I unlock them to delete them, or make changes?

pic of locked files]

tatsu
  • 3,346
U.A
  • 167

2 Answers2

1

You may not be the file owner of these folders and files. They may have been created with root access, which a user would not be able to perform modifications.

You can verify this by opening a terminal in that folder by right-clicking on empty space in the folder and selecting "Open in Terminal" :

open in terminal

You may then find out what the rights and ownership are by typing:

ls -alF

Then if you need to change the owner of a file you can do:

sudo chown $USER the_file

You can also change the rights to the file:

sudo chmod +rw the_file

You may perform both of the aforementioned actions using this one command alternatively:

sudo chown $USER:$USER the_file

You may do a lot of files and folders at once by going to the parent of the highest folder where this happens, opening a terminal at that location and typing:

sudo chown -R $USER the_first_problematic_folder/*
sudo chmod -R +rw the_first_problematic_folder/*

This should give you back rights to the files.

Unless they are on a network drive and you are not granted rights to modify the rights to these files by the way the drive is mounted.

Follow this answer here : XAMPP VirtualHost in Other Directory 403 Forbidden Error for more specifics.

Artur Meinild
  • 31,035
tatsu
  • 3,346
0

Let's take a look at basic file ownership.

Here's a file that I own. I can change it or delete it because I own it:

    $ ls -l testfile
    -rw-r--r-- 1 frank frank 0 Jul  5 07:12 testfile
                 //Owner is "frank", Group is "frank"

Let's change the ownership. Let's give the file to the user 'helen':

    $ sudo chown helen:helen testfile    //New owner is "helen", new group is "helen"
    $ ls -l testfile
    -rw-r--r-- 1 helen helen 0 Jul  5 07:12 testfile 
    //See how the ownership has changed?  
    //When owned by helen, I cannot change or delete the file anymore.
    //The lock appears in the GUI icons.

Let's change the ownership back to me, so I can make changes and get rid of the lock icons:

    $ sudo chown frank:frank testfile 
user535733
  • 68,493