Linux interview questions
Common Linux questions for support and junior DevOps interviews, with answers that explain the method.
755 gives the owner read, write and execute, and gives group and others read and execute, so it suits scripts and directories. 644 gives the owner read and write and everyone else read only, which suits normal files. I would explain it by adding the values: 4 for read, 2 for write and 1 for execute.
I run systemctl status on the service to see whether it is running and read the last log lines. Then I check journalctl -u for the full error and look at disk space with df -h, since a full disk often stops services. After fixing the cause, I restart and confirm the status and the website.
I find its PID with ps aux and grep or with top, then send kill PID, which is SIGTERM and lets it close cleanly. If it is still running after a short wait, I use kill -9, knowing that the process cannot save its state. I also check the logs afterwards to see why it hung.
A single > writes output to a file and replaces what was there, while >> appends to the end. 2>&1 sends standard error to the same place as standard output, so a command like script.sh > run.log 2>&1 saves both into one file.
I start with df -h to see which filesystem is full, then use du -sh on the main directories to see which one is large. find with -size, for example find /var -size +500M, lists big files directly. Often it is an old log, so I check whether log rotation is set up before deleting anything.
start runs the service now but does not change what happens after a reboot. enable sets the service to start at boot but does not start it now. If I install a new service, I usually run systemctl enable --now so it runs immediately and after every reboot.
Practise out loud. Say each answer once as written, then again in your own words with your own number or story.
Have a number ready. "My Linux score is at benchmark on a timed test" is a stronger answer than "I am good at it". Take the test and quote the result.
More in Cloud and DevOps