Interview Q&A / Linux & Shell

INTERVIEW Q&A · 63 QUESTIONS

Linux & Shell interview questions

Permissions, processes, pipes and the commands you are expected to know cold.

  1. How do you read the output of systemctl status?

    The header shows Loaded (unit file path and whether it is enabled) and Active (running, inactive or failed, with how long). Below come the main PID, memory and CPU use, the process tree and the last log lines, which usually reveal why a service failed.

    BeginnerQuick answer1 min read
  2. What is the difference between systemctl start and systemctl enable?

    start runs a service right now, while enable makes it start automatically at boot. They are independent: a service can be running but disabled, or enabled but stopped. systemctl enable --now does both in one command.

    BeginnerQuick answer1 min read
  3. 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
  4. 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
  5. 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
  6. What is a systemd timer, and how does it differ from cron?

    A systemd timer is a .timer unit that starts a matching .service on a schedule or after boot. Unlike cron, its output goes to the journal, it can run missed jobs after downtime with Persistent=true, and it supports dependencies and resource limits.

    AdvancedQuick answer1 min read