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,107
U.A
  • 167
  • 2
    Files outside your /home directory are generally owned by a different user instead of you. You cannot delete their files, they cannot delete your files. Best practice is to save your files to your /home dir, so you own them. – user535733 Jul 05 '19 at 05:01
  • @user535733 I'm already inside the /home dir, /home/usama/EDU/full-stack/grahql-tm – U.A Jul 05 '19 at 12:09
  • 1
    What is the output of ls -l /home/usama/EDU/full-stack/grahql-tm/client? – Kulfy Jul 05 '19 at 12:13

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
  • 26,018
tatsu
  • 3,107
  • 2
    yup, typo. I added your answer. I think this user is out of his league as-is with the terminal so I found the simplest approach I could. notice I didn't introduce cd and instead suggested opening different terminals for each dir, using the GUI. – tatsu Jul 05 '19 at 12:52
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
  • 62,253