2

I copied some files from a data DVD to /home/emma (ext4), and all of the files are read only.

This is what all of the files are like:

emma@emma-W54-55SU1-SUW:~$ stat cd/Drivers/Drivers_List.rtf
  File: ‘cd/Drivers/Drivers_List.rtf’
  Size: 28120       Blocks: 56         IO Block: 4096   regular file
Device: 801h/2049d  Inode: 656521      Links: 1
Access: (0400/-r--------)  Uid: ( 1000/    emma)   Gid: ( 1000/    emma)
Access: 2014-01-17 05:34:46.000000000 +0000
Modify: 2014-01-17 05:34:46.000000000 +0000
Change: 2015-02-01 23:11:04.226865424 +0000
 Birth: -

When I try to delete them, I get rm: cannot remove ‘cd/Drivers/Drivers_List.rtf’: Permission denied, even though I'm the owner. Changing the mode to 777 doesn't work either. The only thing that works is deleting them as root, using sudo.

I thought only an i attribute made files unable to be deleted by their owner, so what's going on?

I'm using Xubuntu 14.10.

Results of various commands:

(Please note: I created directory cd myself, and then copied directory Drivers to it from the DVD.)

emma@emma-W54-55SU1-SUW:~$ ls -dlh cd
drwxrwxr-x 3 emma emma 4.0K Feb  3 01:44 cd

emma@emma-W54-55SU1-SUW:~$ ls -dlh cd/Drivers
dr-x------ 11 emma emma 4.0K Feb  3 02:15 cd/Drivers

emma@emma-W54-55SU1-SUW:~$ ls -l cd/Drivers/Drivers_List.rtf
-r-------- 1 emma emma 28120 Jan 17  2014 cd/Drivers/Drivers_List.rtf
emma@emma-W54-55SU1-SUW:~$ rm cd/Drivers/Drivers_List.rtf
rm: cannot remove ‘cd/Drivers/Drivers_List.rtf’: Permission denied

emma@emma-W54-55SU1-SUW:~$ chmod 660 cd/Drivers/Drivers_List.rtf
emma@emma-W54-55SU1-SUW:~$ ls -l cd/Drivers/Drivers_List.rtf
-rw-rw---- 1 emma emma 28120 Jan 17  2014 cd/Drivers/Drivers_List.rtf
emma@emma-W54-55SU1-SUW:~$ rm cd/Drivers/Drivers_List.rtf
rm: cannot remove ‘cd/Drivers/Drivers_List.rtf’: Permission denied

emma@emma-W54-55SU1-SUW:~$ chmod 777 cd/Drivers/Drivers_List.rtf
emma@emma-W54-55SU1-SUW:~$ ls -l cd/Drivers/Drivers_List.rtf
-rwxrwxrwx 1 emma emma 28120 Jan 17  2014 cd/Drivers/Drivers_List.rtf
emma@emma-W54-55SU1-SUW:~$ rm cd/Drivers/Drivers_List.rtf
rm: cannot remove ‘cd/Drivers/Drivers_List.rtf’: Permission denied

emma@emma-W54-55SU1-SUW:~$ lsattr cd/Drivers/Drivers_List.rtf
-------------e-- cd/Drivers/Drivers_List.rtf

emma@emma-W54-55SU1-SUW:~$ ls -alh cd/Drivers
total 48K
dr-x------ 11 emma emma 4.0K Feb  3 02:15 .
drwxrwxr-x  3 emma emma 4.0K Feb  3 01:44 ..
dr-x------  7 emma emma 4.0K Jan 14  2014 01Chipset
dr-x------  3 emma emma 4.0K Jan 14  2014 02Video
dr-x------  9 emma emma 4.0K Jan 14  2014 03Lan
dr-x------  9 emma emma 4.0K Jan 14  2014 04CReader
dr-x------  3 emma emma 4.0K Jan 17  2014 05Touchpad
dr-x------  3 emma emma 4.0K Jan 14  2014 06Airplane
dr-x------  2 emma emma 4.0K Jan 17  2014 07Hotkey
dr-x------ 12 emma emma 4.0K Jan 14  2014 08IME
dr-x------  7 emma emma 4.0K Jan 14  2014 09Audio
-r--------  1 emma emma  162 Feb 24  2012 ~$ivers_List.rtf

(I've already deleted cd/Drivers/Drivers_List.rtf using sudo as a test.)

  • What does grep /home /etc/mtab say, just for completeness' sake? – Ulrich Schwarz Feb 2 '15 at 17:01
  • grep /home /etc/mtab returns no matches. – EmmaV Feb 2 '15 at 17:22
  • 3
    What are the permissions on the cd and Drivers directories? – terdon Feb 2 '15 at 17:33
  • How come you run stat Drivers/Drivers_List.rtf but the output is for cd/Drivers/Drivers_List.rtf? What is the relationship between the two? – a CVn Feb 2 '15 at 18:59
  • @MichaelKjörling: I forgot to copy the emma@emma-W54-55SU1-SUW:~$ stat cd/Drivers/Drivers_List.rtf line, so I added it in later, but I omitted the cd/ part by mistake. – EmmaV Feb 2 '15 at 22:05
2

I believe some additional information is necessary for a certain answer, but I would suspect the issue is simply permissions related. I'm guessing either you accidentally copied symlinks over instead of the real files, or you're trying to delete the entire directory but haven't reset permissions on all the files within.

First things first, when you stat the file it gives a path of 'cd/Drivers/Drivers_List.rtf', which seems to be different than the directory you're referencing in your commands. Can you confirm that you copied the files instead of creating symlinks? Providing the results of these three commands would be very useful in seeing what's going on:

  • ls -alhd /home/emma/cd
  • ls -alhd /home/emma/Drivers
  • ls -alh /home/emma/Drivers

Second, please attempt the following to see if you can remove a single file from the collection:

  • chmod 660 "/home/emma/Drivers/Drivers_List.rtf"
  • rm "/home/emma/Drivers/Drivers_List.rtf"

Let us know how that goes, and provide any errors you receive!

| improve this answer | |
  • Thanks. Regarding the path discrepancy, I forgot to copy the emma@emma-W54-55SU1-SUW:~$ stat cd/Drivers/Drivers_List.rtf line, so I added it in later, but I omitted the cd/ part by mistake. Regarding symlinks, yes I am 100% certain that I copied files and not symlinks. I used Midnight Commander, with 'Preserve attributes' checked. I'll try what you suggested and report back when I get a chance. – EmmaV Feb 2 '15 at 22:18
  • I've added all of the results of the commands now. I've also discovered that not even chmod 777 makes them able to be deleted, so I must have made a mistake the first time. – EmmaV Feb 3 '15 at 2:39
  • Ah, I see. Took a bit of looking, but I believe doing a chmod u+w -R ~/cd will do the trick for you. To delete a file, you need write permissions to the directory that file is in, not just the file itself (ref: stackoverflow.com/questions/8175697/… and unix.stackexchange.com/questions/49638/…) – immortal squish Feb 3 '15 at 20:55
0

As you're working on a ext4 filesystem it could be possible that those files have the inmutable attribute enabled. You should check it with lsattr. Ex:

antonio@PC1:~/antonio/borrar$ lsattr undelete 
-u--i--------e-- undelete
| improve this answer | |
  • Thanks for your suggestion, but they aren't immutable. If they were, I wouldn't have been able to delete them using sudo. – EmmaV Feb 2 '15 at 22:12
0

Try doing:

sudo rm path/to/file

if you cant do that then try

sudo rm -r path/to/file
| improve this answer | |
  • Thanks for the suggestion. I already stated that sudo works. What I'm asking is why I can't delete the files without using sudo when I'm the owner. – EmmaV Feb 2 '15 at 22:10
  • because when talking about computers, the computer does know who the actual owner is, but everything saved on your account of the computer, you are the owner of. Anything from or copied from another place (other than the web), will always have different permissions. – Viraj Shah Feb 3 '15 at 2:02
0

I've found the answer myself here.

Because cd/Drivers is read-only, only root can delete from it.

| improve this answer | |
0

I was about to answer with the issue being you're trying to remove a read-only file inside of a directory you have write permissions on.

Try resetting the permissions on the folder recursively with chmod -R 700 /home/emma/cd

It'll be from when you copied preserving permissions inside of MC.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.