Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a directory with log files and I'm putting logs from script launched by users into them. Logging with syslog doesn't seem possible in this case. (non-daemon rsync)

I want the users to have only write permissions on log files. The problem is, that write permissions must be further restricted, so that users (script) can only append to that files. The underlying filesystem is XFS.

The following doesn't work:

# chattr +a test.log
chattr: Inappropriate ioctl for device while reading flags on test.log

Is there any other solution for this? Thank you for your hints.

share|improve this question
Are you sure it's XFS? chattr +a works for me here (3.2 kernel). Note that you need to be root to use chattr (a $ prompt suggests non-superuser), though you'd get a different error message if chattr +a was supported and you were not root. – Stéphane Chazelas Dec 30 '12 at 22:02
What is the mount options on the partition? It might possibly store it using xattr, which might need the relevant mount option? (The socumentation for XFS don't mention much about it either...) – Gert van den Berg Dec 31 '12 at 9:40
This closed on SF, so I'm leaving it open here – Michael Mrozek Dec 31 '12 at 17:29
up vote 5 down vote accepted

The chattr utility is written for ext2/ext3/ext4 filesystems. It emits ioctls on the files, so it's up to the underlying filesystem to decide what to do with them. The XFS driver in newer Linux kernels supports the same FS_IOC_SETFLAGS ioctl as ext[234] to control flags such as append-only, but you may be running an older kernel where it doesn't (CentOS?). Try using the xfs_io utility instead:

echo chattr +a | xfs_io test.log

Note that, for XFS like for ext[234], only root can change the append-only flag (more precisely, you need the CAP_LINUX_IMMUTABLE capability).

share|improve this answer

Do you have permissions to do that? From man 1 chattr:

A file with the `a' attribute set can only be open in append mode for writing. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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