Founding prices until 15 December: 30% off Pro, locked for life. See pricing

Linux interview questions

4 questions. Full disks, permission denied, ports already in use and services that won't start. Each has a strong answer of about a minute and the points an interviewer listens for.

  1. 01

    You get an alert: the root disk on a server is 98% full. What do you do?

    A strong answer

    First df -h to confirm which filesystem is full. Then I find what's using it, du -sh on the big directories sorted by size, or ncdu, usually ending up in /var/log or an application's data folder. I'd clean up safely: compress or remove old rotated logs, or vacuum the journal. If the space doesn't come back after deleting, lsof shows files that are deleted but still held open by a process, which needs a restart of that process. Then I'd make sure logrotate is configured and there's an alert at 80%, so it doesn't happen again.

    What the interviewer listens for

    • Confirm which filesystem is full. First confirm what's full and how much is left.
    • Find what is using the space. du (sorted) or ncdu shows where the space went.
    • Clean up safely, often old logs. Logs are the usual suspect, and rotating or compressing them is the safe fix.
    • Watch for deleted files still held open. Deleting a file a process still writes to frees nothing. Knowing this stands out.
    • Prevent it happening again. A good answer ends with log rotation or alerting so it doesn't come back.

    Likely follow-up: “df says the disk is full but du only finds half of it. Why?”

    Practise answering it
  2. 02

    An app can't read its config file: 'Permission denied'. How do you investigate and fix it?

    A strong answer

    I'd check the file with ls -l to see its owner, group and mode, and check which user the app runs as, with ps or the service's unit file. If that user isn't the owner and the group or others can't read it, I'd fix it minimally: chown the file to the app's user, or add the user to a group with read access, and chmod 640. I'd also check the parent directories, because the user needs execute permission on every directory in the path. I wouldn't use chmod 777 or run the app as root.

    What the interviewer listens for

    • Check the owner and permissions. ls -l shows the owner, group and mode, which is usually enough.
    • Check which user the app runs as. The question is always "can THIS user read it", so find out who the process runs as.
    • Fix with chown or chmod, minimally. Change ownership or permissions just enough.
    • Remember the directories need execute permission. A readable file in a directory you can't enter is still unreadable. This detail stands out.

    Likely follow-up: “The permissions look right but it's still denied. What else could it be?”

    Practise answering it
  3. 03

    Your service won't start: 'address already in use' on port 8080. How do you find out what's using it?

    A strong answer

    I'd run ss -ltnp | grep 8080, or lsof -i :8080, to see which process is listening and its PID. Then ps or systemctl status to understand what it is. Often it's an old copy of the same service that didn't stop, or another app configured on the same port. Then I'd stop it properly with systemctl stop, or if both need to run, change one of them to a different port.

    What the interviewer listens for

    • Find the process listening on the port. ss -ltnp (or lsof -i :8080) names the process holding the port.
    • Identify what that process is. Before stopping it, know what it is. It may be another copy of your own service.
    • Stop it properly or change the port. Stop it cleanly through its service manager, or move one of the two to another port.

    Likely follow-up: “ss shows nothing listening, but the error persists. What could it be?”

    Practise answering it
  4. 04

    You run systemctl start myapp and it fails. What are your next steps?

    A strong answer

    First systemctl status myapp: it shows if it failed, the exit code and the last log lines. Then journalctl -u myapp -n 50 for the full error, like a missing file, a wrong path or a permission problem. I'd check the unit file with systemctl cat myapp, the ExecStart path, the user and the environment, and try running the command by hand as that user. After changing the unit file I'd run systemctl daemon-reload before starting it again.

    What the interviewer listens for

    • Check the status. Status shows whether it failed, the exit code and the last log lines.
    • Read the logs with journalctl. journalctl -u myapp shows why it failed.
    • Check the unit file. Wrong paths, users or environment in the unit file are common causes.
    • Reload systemd after editing. Forgetting daemon-reload after editing a unit is a classic mistake. Mentioning it shows hands-on experience.

    Likely follow-up: “It starts, then stops a few seconds later. What would you look at?”

    Practise answering it

Ready for the real thing?

A timed interview asks questions like these one at a time, adds quick questions, a design and a hands-on task on a real machine, and ends with a hire or no-hire scorecard.

Take a practice interview