« Yet Another Reason I Love Linux | Main | My Take on the HD Format War »

File Attributes in Linux

Got an interesting, new error message tonight when trying to copy out a network config file to a new server:

scp: /etc/resolv.conf: Operation not permitted

The same error would present itself when I tried to edit the file in vi, or echo something to overwrite it. However, it would let me do a "echo # testing >> /etc/resolv.conf" so appending to the end of the file was working somehow. It turns out that ext filesystems, in addition to their read/write/execute permissions, also have "attributes". These can be used to, among other things, make it so a file can have things appended to it, but not be overwritten:

# lsattr /etc/resolv.conf
-----a------- /etc/resolv.conf
# chattr -a /etc/resolv.conf
# lsattr /etc/resolv.conf
------------- /etc/resolv.conf

Why was resolv.conf set like this when I've never seen this before on any Linux system? I hope this was just a fluke and not part of some new update to Red Hat Enterprise Linux 3, but at least I know how to fix it if it crops up again. Hooray for the Ubuntu forums and their having a thread from a user who saw this happen in Ubuntu. And, of course, huzzah for man pages :)

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on November 19, 2007 2:04 AM.

The previous post in this blog was Yet Another Reason I Love Linux.

The next post in this blog is My Take on the HD Format War.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.34