CompTIA Server+ (SK0-005)TroubleshootingMedium

A server administrator discovers that a newly installed application on a Linux server is failing to start, reporting 'Permission denied' errors in its logs when trying to create a log file in `/var/log/myapp`. The application runs as a dedicated user `myappuser`. What command should the administrator use to MOST efficiently resolve this specific issue?

  1. A`sudo systemctl restart myapp`
  2. B`mv /var/log/myapp /tmp`
  3. C`chmod 777 /var/log/myapp`
  4. D`chown myappuser:myappgroup /var/log/myapp`
Show answer & explanation

Correct answer: D. `chown myappuser:myappgroup /var/log/myapp`

The error 'Permission denied' when `myappuser` tries to write to `/var/log/myapp` indicates that `myappuser` does not have the necessary write permissions for that directory. Changing the ownership of the directory to `myappuser` (and an appropriate group) is the most secure and efficient way to grant the necessary permissions without over-permissive `chmod 777`.

Why the other options are wrong

  • A. Restarting the service will not resolve a file system permission issue; the error will simply recur.
  • B. Moving the log directory to `/tmp` might temporarily allow writing, but it's not a permanent solution, changes the intended log location, and `/tmp` is often cleared on reboot.
  • C. `chmod 777` grants full permissions to everyone, which is a major security risk and should be avoided unless absolutely necessary for temporary troubleshooting.

Linux File Ownership & Permissions

In Linux, file and directory access is controlled by ownership (user, group) and permissions (read, write, execute) for the owner, group, and others. Both must be correctly configured for applications to function.

  • `chown` changes ownership (user and/or group).
  • `chmod` changes file/directory permissions.
  • Applications often need write permissions to their log directories or configuration files.
  • Security best practice is to grant only the minimum necessary permissions.

Memory trick: Permission Denied? Check who owns the file, then who can read/write!

More Troubleshooting questions