A Linux systems administrator needs to create a compressed gzip archive of the directory `/var/log/audit` named `audit_backup.tar.gz`. Once created, the administrator must assign ownership of the new file to the user `secadmin` and the group `auditteam`. Which of the following command sequences correctly completes both tasks?
- tar -czvf audit_backup.tar.gz /var/log/audit && chown secadmin:auditteam audit_backup.tar.gzAnswer
- Btar -xzvf audit_backup.tar.gz /var/log/audit && chmod secadmin:auditteam audit_backup.tar.gz
- Cdd if=/var/log/audit of=audit_backup.tar.gz && chown secadmin:auditteam audit_backup.tar.gz
- Dtar -czvf audit_backup.tar.gz /var/log/audit && chmod 775 audit_backup.tar.gz
Answer
The command sequence tar -czvf audit_backup.tar.gz /var/log/audit && chown secadmin:auditteam audit_backup.tar.gz correctly creates the compressed archive and sets file ownership.
The `tar` utility with the `-czvf` options creates (`-c`), gzips (`-z`), verbosely logs (`-v`), and outputs to file (`-f`) the compressed archive from the specified directory. Following archive creation, `chown owner:group` is the standard Linux/macOS command to change both user and group ownership of the target file.
Step-by-Step Solution
Key Concept
Linux Archiving and Ownership Management