ACSP - Apple Certified Support Professional Command-Line Interface Questions and Answers 1 — Questions and Answers
Question 1: A technician needs to find all files ending with the `.log` extension within the `/Users/Shared/` directory that have been modified in the last 48 hours. Which of the following commands is the most precise way to accomplish this?
- ls -lt /Users/Shared/*.log
- find /Users/Shared/ -name "*.log" -mtime -2 (Correct answer)
- grep -r ".log" /Users/Shared/
- mdfind -onlyin /Users/Shared/ "kind:log"
Correct answer: find /Users/Shared/ -name "*.log" -mtime -2
The `find` command is the standard utility for searching file hierarchies based on specific criteria. The path `/Users/Shared/` sets the starting point, `-name "*.log"` filters for files matching the log extension, and `-mtime -2` specifically selects files with a modification time of less than two 24-hour periods ago.
Question 2: In the command `ps aux | grep 'Final Cut Pro'`, what is the primary function of the pipe `|` character?
- It runs the `ps` and `grep` commands simultaneously in parallel.
- It saves the output of `ps aux` to a file named `grep`.
- It sends the standard output of the `ps aux` command to be used as the standard input for the `grep` command. (Correct answer)
- It compares the output of the two commands to find differences.
Correct answer: It sends the standard output of the `ps aux` command to be used as the standard input for the `grep` command.
The pipe `|` is a core shell feature used for chaining commands. It redirects the standard output (stdout) of the command on its left (`ps aux`) to become the standard input (stdin) for the command on its right (`grep 'Final Cut Pro'`). This allows the `grep` command to filter the process list generated by `ps`.
Question 3: A script named `backup.sh` needs to be run, but when the user tries `./backup.sh`, the shell returns a 'Permission denied' error. The output of `ls -l backup.sh` is `-rw-r--r--`. Which command will make the script executable for the file's owner only?
- chmod 755 backup.sh
- chown root backup.sh
- chmod u+x backup.sh (Correct answer)
- sudo ./backup.sh
Correct answer: chmod u+x backup.sh
The `chmod` command modifies file permissions. The `u+x` syntax specifically adds (`+`) the execute (`x`) permission for the user (`u`) who owns the file. The original permissions `-rw-r--r--` were missing the 'x' bit for the owner, which is required to run the file as a program. `chmod 755` would also work but it would grant execute permissions to the group and others as well, which is more permissive than required.
Question 4: A support professional needs to generate a comprehensive report of a Mac's hardware, including details about memory, PCI cards, and attached USB devices, directly from the command line. Which utility is the command-line equivalent of the System Information app?
- system_profiler (Correct answer)
- hwinfo --all
- sysctl -a
- uname -m
Correct answer: system_profiler
The `system_profiler` command is the command-line interface to the same information framework used by the graphical System Information application. It can be used to generate detailed reports on numerous hardware and software data types.
Question 5: To ensure a critical software update process is not interrupted, an administrator needs to prevent a Mac from sleeping for the duration of a single command. Which of the following is the BEST way to run `softwareupdate -iaR` while temporarily preventing system sleep?
- pmset -a sleep 0; softwareupdate -iaR
- caffeinate softwareupdate -iaR (Correct answer)
- nohup softwareupdate -iaR
- sleep 0; softwareupdate -iaR
Correct answer: caffeinate softwareupdate -iaR
The `caffeinate` command is designed to prevent sleep. When a command is passed as an argument to `caffeinate`, it creates a sleep assertion that remains active only for the life of that command's process. This is the most targeted and safest method, as sleep behavior returns to normal as soon as the command completes. Using `pmset` would change the system's settings persistently.
Question 6: A technician needs to view a live, continuous stream of all new system and application log messages as they are generated to diagnose an intermittent issue. Which command provides this real-time view into the macOS unified logging system?
- tail -f /var/log/system.log
- log show --last 1m
- cat /var/log/syslog
- log stream (Correct answer)
Correct answer: log stream
The `log stream` command taps directly into the macOS unified logging system and displays messages from all subscribed processes in real-time as they are created. While `tail -f` was used for legacy log files, it does not work with the modern unified logging database. `log show` is used for querying historical logs, not for live streaming.
A technician needs to find all files ending with the `.log` extension within the `/Users/Shared/` directory that have been modified in the last 48 hours.
Which of the following commands is the most precise way to accomplish this?