You are not logged in.

#1 2014-11-15 02:33:32

hcra
Member
From: Oregon
Registered: 2013-04-20
Posts: 56

[SOLVED]How to remove a read-only file?

I converted from MBR/Syslinux to GPT/Gummiboot, thanks to the help of forum member Head_on_a_Stick.

I'm trying to clean-up my /boot directory and would like to remove the old /boot/syslinux directory. I began by trying to remove the only file in the directory. When I rm the file as root with any of the possible options, terminal consistently reports

cannot remove ‘ldlinux.sys’: Operation not permitted.

The attributes of the file are

-r--r--r-- 1 root root 61440 Oct 16 18:44 ldlinux.sys

I'm stuck. How do I go about removing the file?

Last edited by hcra (2014-11-15 04:46:16)

Offline

#2 2014-11-15 02:40:50

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,523

Re: [SOLVED]How to remove a read-only file?

You probably need to remove files from within a Live distro as administrator.


do it good first, it will be faster than do it twice the saint wink

Offline

#3 2014-11-15 02:47:54

hcra
Member
From: Oregon
Registered: 2013-04-20
Posts: 56

Re: [SOLVED]How to remove a read-only file?

TheSaint wrote:

You probably need to remove files from within a Live distro as administrator.

I tried that, or at least I think did, when I chrooted in to install Gummiboot. I could give it another go I suppose.

[EDIT]removed extraneous information.

Last edited by hcra (2014-11-15 03:13:13)

Offline

#4 2014-11-15 03:19:17

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED]How to remove a read-only file?

# ls -l foo
-r--r--r-- 1 root root 0 Nov 15 04:17 foo
# rm foo
# ls -l foo
ls: cannot access foo: No such file or directory

Am I missing something?

Offline

#5 2014-11-15 03:24:29

hcra
Member
From: Oregon
Registered: 2013-04-20
Posts: 56

Re: [SOLVED]How to remove a read-only file?

karol wrote:

Am I missing something?

I'm only reporting what terminal reports even with -f. Not sure what to say.

Offline

#6 2014-11-15 03:25:43

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,532
Website

Re: [SOLVED]How to remove a read-only file?

I'm guessing your boot partition is mounted read only.

What is the output of `mount`?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2014-11-15 03:32:14

hcra
Member
From: Oregon
Registered: 2013-04-20
Posts: 56

Re: [SOLVED]How to remove a read-only file?

Trilby wrote:

What is the output of `mount`?

See pastebin please.

Offline

#8 2014-11-15 03:35:49

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED]How to remove a read-only file?

Post he output of

ls -l /boot/

Offline

#9 2014-11-15 03:37:45

hcra
Member
From: Oregon
Registered: 2013-04-20
Posts: 56

Re: [SOLVED]How to remove a read-only file?

karol wrote:

Post the output of

ls -l /boot/
-rw-r--r-- 1 root root 17410352 Nov  2 07:26 initramfs-linux-fallback.img
-rw-r--r-- 1 root root  3409472 Nov  2 07:26 initramfs-linux.img
-rw-r--r-- 1 root root   648704 Oct 12 05:05 intel-ucode.img
drwxr-xr-x 2 root root     4096 Nov 14 12:48 syslinux
-rw-r--r-- 1 root root  4025888 Oct 30 12:51 vmlinuz-linux

Offline

#10 2014-11-15 03:40:12

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED]How to remove a read-only file?

Have you tried removing  it from a liveCD / liveUSB? No need to chroot.

Offline

#11 2014-11-15 03:41:55

hcra
Member
From: Oregon
Registered: 2013-04-20
Posts: 56

Re: [SOLVED]How to remove a read-only file?

karol wrote:

Have you tried removing it from a liveCD / liveUSB?

I'll try straight away and report back.

[EDIT]same result:

Operation not permitted

Last edited by hcra (2014-11-15 03:46:53)

Offline

#12 2014-11-15 04:26:04

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: [SOLVED]How to remove a read-only file?

hcra wrote:
karol wrote:

Have you tried removing it from a liveCD / liveUSB?

I'll try straight away and report back.

[EDIT]same result:

Operation not permitted

I'm going to ask a REALLY stupid question but, hey, SOMEONE has to ask it... (Sorry. sad)

You are trying to delete the file from your hard drive (that you mount yourself by hand) and NOT the file from the live environment, right?

Last edited by drcouzelis (2014-11-15 04:26:22)

Offline

#13 2014-11-15 04:36:14

hcra
Member
From: Oregon
Registered: 2013-04-20
Posts: 56

Re: [SOLVED]How to remove a read-only file?

I'm going to ask a REALLY stupid question …

I already accidentally deleted the same file from the ISO before I realized that is was in the wrong /boot directory (blush). I thought the problem was solved, but alas not. Actually, a really great question!I

I'm booting with Gummiboot on the ISO and my installation.

Offline

#14 2014-11-15 04:41:36

circleface
Member
Registered: 2012-05-26
Posts: 639

Re: [SOLVED]How to remove a read-only file?

The file is set to be immutable, so you must remove that attribute before you can delete it.

# chattr -i ldlinux.sys
# rm ldlinux.sys

Offline

#15 2014-11-15 04:47:03

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED]How to remove a read-only file?

Ah, yes:

$ lsattr /boot/syslinux/ldlinux.sys
----i--------e-- /boot/syslinux/ldlinux.sys

Thanks, circleface.

Offline

#16 2014-11-15 04:48:20

hcra
Member
From: Oregon
Registered: 2013-04-20
Posts: 56

Re: [SOLVED]How to remove a read-only file?

circleface wrote:

The file is set to be immutable, so you must remove that attribute before you can delete it.

Success. That worked. Thanks, Circleface!!

One question: how can you tell that a file is set immutable?

Offline

#17 2014-11-15 04:50:34

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,561

Re: [SOLVED]How to remove a read-only file?

lsattr will tell you.

Offline

#18 2014-11-15 04:53:01

hcra
Member
From: Oregon
Registered: 2013-04-20
Posts: 56

Re: [SOLVED]How to remove a read-only file?

Scimmia wrote:

lsattr will tell you.

Thanks for your help, everyone!!

Offline

#19 2014-11-15 04:59:11

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: [SOLVED]How to remove a read-only file?

What do you know. So

-r--r--r--

is like "if you wouldn't mind, please don't modify this file" and

----i--------e--

is like I don't THINK so. This file's going NOWHERE, PUNK. ..?

Offline

#20 2014-11-15 05:09:21

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED]How to remove a read-only file?

pacman used to use immutable file for db lock, but it doesn't anymore:

$ ls -l /var/lib/pacman/db.lck
---------- 1 root root 5 Nov 15 06:04 /var/lib/pacman/db.lck
$ lsattr /var/lib/pacman/db.lck
lsattr: Permission denied While reading flags on /var/lib/pacman/db.lck

U Can't touch this!

$ sudo lsattr /var/lib/pacman/db.lck
-------------e-- /var/lib/pacman/db.lck

Offline

#21 2014-11-15 05:13:08

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,561

Re: [SOLVED]How to remove a read-only file?

drcouzelis wrote:

What do you know. So

-r--r--r--

is like "if you wouldn't mind, please don't modify this file" and

----i--------e--

is like I don't THINK so. This file's going NOWHERE, PUNK. ..?

Pretty much. Even with 000 permissions, the root user (or any process running as root) can still read, modify, and delete the file. When set as immutable, nothing can change it.

Offline

#22 2014-11-15 12:08:53

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,523

Re: [SOLVED]How to remove a read-only file?

hcra wrote:

when I chrooted in to install Gummiboot

I think the best chance was to mount the partition and delete files without chroot into the partition. Otherwise you may fall into the same permissions problem.


do it good first, it will be faster than do it twice the saint wink

Offline

Board footer

Powered by FluxBB