Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[Rehat Linux] Cannot delete write-protected file. help!

Status
Not open for further replies.

linuxtricks

IS-IT--Management
May 24, 2000
111
US
Somehow I must've write-protected the file: /etc/inetd.conf<br>I need to modify the file... but I can't.&nbsp;&nbsp;It does not give me access to this file - not even as root.<br><br>How can I take control of this file?<br><br>Here's some more detail to help you help me.&nbsp;&nbsp;Thanks!<br><br>[root@preweb /etc]#<b> ls -l inetd.conf</b><br>-rw-------&nbsp;&nbsp;&nbsp;1 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3008 Apr&nbsp;&nbsp;6 00:32 inetd.conf<br><br>[root@preweb /etc]# <b>stat inetd.conf</b><br>&nbsp;&nbsp;File: &quot;inetd.conf&quot;<br>&nbsp;&nbsp;Size: 3008&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Filetype: Regular File<br>&nbsp;&nbsp;Mode: (0600/-rw-------)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Uid: (&nbsp;&nbsp;&nbsp;&nbsp;0/&nbsp;&nbsp;&nbsp;&nbsp;root)&nbsp;&nbsp;Gid: (&nbsp;&nbsp;&nbsp;&nbsp;0/&nbsp;&nbsp;&nbsp;&nbsp;root)<br>Device:&nbsp;&nbsp;3,8&nbsp;&nbsp;&nbsp;Inode: 26400&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Links: 1&nbsp;&nbsp;&nbsp;&nbsp;<br>Access: Mon May 29 22:18:02 2000(00000.00:07:02)<br>Modify: Thu Apr&nbsp;&nbsp;6 00:32:06 2000(00053.21:52:58)<br>Change: Thu Apr&nbsp;&nbsp;6 00:33:44 2000(00053.21:51:20)<br><br>[root@preweb /etc]# <b>rm -f inetd.conf</b><br>rm: cannot unlink `inetd.conf': Operation not permitted<br>[root@preweb /etc]# <br><br>??? HELP! <p> <br><a href=mailto: > </a><br><a href= > </a><br><i>try not!</i><br>
<i>do... or do not. there is no try!</i>
 
From the permissions you listed (&quot;-rw-------&quot;), &quot;root&quot; should be able to read and write the file.&nbsp;&nbsp;I don't know why it's not letting you delete the file, but I'm also not sure why you'd want to.&nbsp;&nbsp;This file is needed by <FONT FACE=monospace>inetd</font> for it to run correctly.<br><br>In fact, I think the problem might be that <FONT FACE=monospace>inetd</font> is using the file and has locked it, preventing you from deleting it.<br><br>What is it you're trying to do?&nbsp;&nbsp;There may be another way :)<br>
 
Actually, the reason I was trying to delete it was because I made a copy of the file with *access* so I can modify it.<br><br>When I attemped to uninstall Samba-2.0.5a, it tried to make a change to inetd.conf but could not. Therefore, the operation failed.<br><br>-----------------------------<br>chmod: /etc/inetd.conf: Operation not permitted<br>execution of script failed<br>-----------------------------<br>So I tried to write to that file (as root) and couldn't.<br>I tried to run a chmod on it and couldn't.&nbsp;&nbsp;(WHY!!!)<br><br>So I made a copy of it... in the same dir. then tried to delete the original one... and COULDN'T!<br><br>blah!&nbsp;&nbsp;&nbsp;I hate being a newbie!<br><br>Maybe the file was in use...(?)&nbsp;&nbsp;Could there have been some way to stop the services on that file... so I can write to it... then restart the services?<br><br>Thanks for the help! <p> <br><a href=mailto: > </a><br><a href= > </a><br><i>try not!</i><br>
<i>do... or do not. there is no try!</i>
 
Normally, I work the other way - take a backup copy of &quot;inetd.conf&quot;, then just use &quot;vi&quot; to edit &quot;inetd.conf&quot;, then do a &quot;killall -HUP inetd&quot; to force inetd to re-read &quot;inetd.conf&quot;.<br><br>If you're trying to copy a new file to &quot;inetd.conf&quot; you are going to get the same file locking problems that you see when you try to remove it.&nbsp;&nbsp;&quot;cp&quot; will, if memory serves, actually remove the original file you are copying to before it puts the new copy in place.<br><br>Try editing &quot;inetd.conf&quot; as described above, see if that works for you.
 
A friend of mine said that the file must have had something added to it... (some type of immutable-ness) so that even root couldn't touch it.<br><br>I *do* remember playing around with something that did that to files (a long time ago)... and I might've did that to the inetd.conf file.<br><br>Do you know of anyway to get around having a file immutable?<br>Nothing was does to the kernel... so it must've just been a command that executed it. <p> <br><a href=mailto: > </a><br><a href= > </a><br><i>try not!</i><br>
<i>do... or do not. there is no try!</i>
 
try <br>chattr = filename<br><br>lsattr inetd.conf should show<br>--------- inetd.conf
 
Ah - here it is - was looking for this post yesterday and couldn't find it.&nbsp;&nbsp;I ended up posting a tip over in &quot;Linux (Server)&quot; hoping it would be seen.<br><br>Anyway, <FONT FACE=monospace>chattr</font> might fix things for you.&nbsp;&nbsp;Try <FONT FACE=monospace>chattr -i inetd.conf</font> to remove the &quot;immutable&quot; flag, and <FONT FACE=monospace>chattr +i inetd.conf</font> to add it again.
 
<font color=red>chgwhat and AndyBo,</font><br><br>Thank you for the help.&nbsp;&nbsp;<i>It worked!!!</i><br> <p> <br><a href=mailto: > </a><br><a href= > </a><br><i>try not!</i><br>
<i>do... or do not. there is no try!</i>
 
i downloaded a programme file from the internet but now when i try to delete it, i get the following eror message:<br>make sure file is not full or write protected. I would appreciate any ideas on how to delete this file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top