Interview Q&A / Linux & Shell
Linux & Shell interview questions
Permissions, processes, pipes and the commands you are expected to know cold.
Prefer rapid revision? Practise Linux & Shell short interview answers →
- How do you make systemd restart a service automatically if it crashes?
Set Restart=on-failure (or always) in the [Service] section, usually with RestartSec= to add a delay. systemd then restarts the process after a crash, and StartLimitBurst and StartLimitIntervalSec stop endless crash loops.
IntermediateQuick answer1 min read - How do you write a simple systemd service file for your own app?
Create a .service file in /etc/systemd/system with a [Unit] description, a [Service] section giving ExecStart and a user, and an [Install] section with WantedBy=multi-user.target. Then run systemctl daemon-reload and systemctl enable --now name.
IntermediateQuick answer1 min read - What are systemd targets, and how do they relate to old runlevels?
A target is a group of units that represents a system state, such as multi-user.target (text mode, networking) or graphical.target (with a desktop). They replace SysV runlevels: runlevel 3 is multi-user.target and 5 is graphical.target. Check or change with systemctl get-default and set-default.
IntermediateQuick answer1 min read