A Linux administrator is writing a nightly backup script for a server that enforces SELinux and uses POSIX ACLs. The script must create a bzip2-compressed archive of /srv and store it as /var/backups/srv-$(date +%F).tar.bz2. The archive has to preserve ACLs, SELinux security contexts, and any other extended file attributes so they can be fully restored later. Which of the following command lines meets all of these requirements?
tar -caf /var/backups/srv-$(date +%F).tar.bz2 /srv
tar --acls --xattrs --selinux -cjf /var/backups/srv-$(date +%F).tar.bz2 /srv
tar -cjf /var/backups/srv-$(date +%F).tar.bz2 --preserve-permissions /srv
tar -cjf /var/backups/srv-$(date +%F).tar.bz2 /srv
GNU tar preserves basic ownership and permissions automatically, but it stores discretionary ACLs, SELinux labels, and the rest of a file's extended attributes only when the corresponding feature switches are supplied. The combination --acls --xattrs --selinux enables saving POSIX ACLs, generic xattrs (which include capabilities and other security metadata) and SELinux contexts, respectively. Adding -c (create), -j (bzip2 compression) and -f <archive> produces the required compressed file.
The correct command therefore includes all three metadata options before the conventional -cjf flags:
The correct option string: tar --acls --xattrs --selinux -cjf /var/backups/srv-$(date +%F).tar.bz2 /srv
Why the other choices are wrong:
tar -cjf /var/backups/… /srv compresses the data but omits the metadata switches, so ACLs and SELinux labels are lost.
tar -cjf … --preserve-permissions /srv merely keeps default modes; it still lacks the ACL/xattr/SELinux options.
tar -caf … /srv uses -a to choose compression automatically (it will still pick bzip2), but it does not add the necessary metadata preservation options.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What are POSIX ACLs and why are they important in Linux file systems?
Open an interactive chat with Bash
What role does SELinux play in securing Linux systems?
Open an interactive chat with Bash
What are extended attributes (xattrs), and how do they relate to file metadata?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
System Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access