Server Fault is a question and answer site for system and network administrators. 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've got a Nagios XI install running on CentOS 6.2, and want to modify the backup script. I noticed that the extended attribute bit is set for this shell script, so I want to be sure not to mess anything up when I make changes to it. I experimented and found that "cp -p" does not preserve this setting (see comment for update on this). I'm new to extended attributes on Linux, and found that there's a command 'getfattr' that is supposed to display the extended attributes, however it doesn't display anything for this file.

cd /usr/local/nagiosxi/scripts
-rwxr-x---.  1 nagios nagios   2757 Jul  3 10:03*

# nothing is displayed by 'getfattr':
getfattr -d

# and nothing special seems to be present according to 'getfacl':
# file:
# owner: nagios
# group: nagios

Ultimately, my objective is to modify the file while preserving whatever attributes were set during the original product installation. Is there a reason why the extended attribute bit is set, even though no properties are apparently present according to getfattr?

share|improve this question
Well, I solved one riddle: "cp -p" defaults to "cp --preserve=mode,ownership,timestamps". Using "cp --preserve=all" works and preserves the extended attribute bit. – Alan Aug 10 '12 at 18:31
up vote 10 down vote accepted

The security.selinux extended attribute is not shown by default by getfattr; you must explicitly request it.

$ getfattr -d Work
$ getfattr -n security.selinux Work
# file: Work
share|improve this answer
Thank you. The getfattr man page is very misleading: "-d: Dump the values of all extended attributes associated with pathname." Apparently "all" doesn't mean "ALL". Wow. I found that the option "-m" with the pattern "-" lists "all" attributes. Using the command "getfattr -m -", I see "security.selinux" as the only attribute. – Alan Aug 10 '12 at 20:30

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.