Question

Difficulty: HardmacOS and Linux Operating System Features and Tools

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?

  1. tar -czvf audit_backup.tar.gz /var/log/audit && chown secadmin:auditteam audit_backup.tar.gzAnswer
  2. B
    tar -xzvf audit_backup.tar.gz /var/log/audit && chmod secadmin:auditteam audit_backup.tar.gz
  3. C
    dd if=/var/log/audit of=audit_backup.tar.gz && chown secadmin:auditteam audit_backup.tar.gz
  4. D
    tar -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

1
Identify the proper command and flags to create a compressed archive.
Use `tar` with flags `-c` (create), `-z` (compress with gzip), `-v` (verbose output), and `-f` (filename argument). Target: `tar -czvf audit_backup.tar.gz /var/log/audit`.
Creating a gzipped archive in Linux/macOS CLI requires the standard tar compression syntax.
2
Identify the command to change file user and group ownership.
Use `chown secadmin:auditteam audit_backup.tar.gz`.
The `chown` command modifies user and group ownership using the `user:group` syntax.

Key Concept

Linux Archiving and Ownership Management
Rate this question