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

EmmaV
  • 4,067

5 Answers5

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!

  • 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 02 '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 03 '15 at 02: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: http://stackoverflow.com/questions/8175697/rm-cannot-remove-permission-denied and http://unix.stackexchange.com/questions/49638/cannot-delete-a-file-permission-denied-why) – immortal squish Feb 03 '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
  • 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 02 '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
  • 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 02 '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 03 '15 at 02:02
0

I've found the answer myself here.

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

EmmaV
  • 4,067
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.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232