Question

Difficulty: Very hardmacOS and Linux Operating System Features and Tools

A systems administrator is performing administrative maintenance on macOS and Linux endpoints within an enterprise environment. The administrator needs to execute two specific command-line operations:

1. Recursively update both the user owner and group owner of the entire directory tree located at `/srv/appdata` to `sysadmin` on a Linux server.
2. Search through the system log `/var/log/auth.log` and display all lines that contain the exact phrase "Failed password" to audit security events.

Which of the following commands will successfully accomplish these tasks? (Select TWO.)

  1. sudo chown -R sysadmin:sysadmin /srv/appdataAnswer
  2. grep "Failed password" /var/log/auth.logAnswer
  3. C
    sudo chmod -R sysadmin:sysadmin /srv/appdata
  4. D
    ps aux | findstr "Failed password" /var/log/auth.log

Answer

The command 'sudo chown -R sysadmin:sysadmin /srv/appdata' successfully changes user and group ownership recursively, while 'grep "Failed password" /var/log/auth.log' searches for and extracts matching string entries from the designated authentication log.
Executing 'sudo chown -R sysadmin:sysadmin /srv/appdata' properly invokes superuser privileges to recursively change both the user owner and group owner of the specified directory path. Executing 'grep "Failed password" /var/log/auth.log' scans the authentication log file directly and outputs any lines containing the target string.

Step-by-Step Solution

1
Identify the proper tool for modifying user and group ownership recursively on Linux/macOS file systems.
Determine that 'chown' (change owner) with the '-R' (recursive) flag and the syntax 'owner:group' modifies directory ownership hierarchy.
The 'chmod' command controls access mode bits (rwx) rather than ownership identity.
2
Identify the proper command line utility for searching text contents within flat files in Linux/macOS environments.
Select 'grep' to search and print matching lines from '/var/log/auth.log'.
'grep' is the standard POSIX utility for matching regular expressions and plain strings inside log files, whereas 'ps' monitors running processes and 'findstr' is a Windows command.

Key Concept

macOS and Linux Command Line Utilities (chown, chmod, grep, ps)
Estimated Time:2m 0s
Rate this question