Page Content

Tutorials

Services And System Management In Linux Interview Questions

Services and system management in linux interview questions

Preparing for a Linux System Administration interview requires a solid grasp of how background processes interact with the kernel. Below is a curated list of technical interview questions and answers focused on services, systemd, and system management.

Core Concepts (Services & Daemons)

Q1: What is the difference between a process, a service, and a daemon?

  • Process: Any running instance of a program (has a PID).
  • Daemon: A background process that starts at boot or after initialization and doesn’t have a controlling terminal (e.g., sshd).
  • Service: A broader term in systemd referring to a daemon that the system can manage (start/stop/restart) using a unit file.

Q2: How does a daemon process differ from a regular user process in terms of its parent?

  • Answer: A regular process is usually a child of the user’s shell. A daemon is typically orphaned by its parent and adopted by the init process (PID 1), which is systemd in modern Linux.

Also read about Understanding Services And System Management In Linux

Systemd and Systemctl

Q3: What is the difference between systemctl start and systemctl enable?

  • Answer:
    • Start: Affects the current session. It runs the service immediately but doesn’t guarantee it will run after a reboot.
    • Enable: Affects future sessions. It creates a symbolic link in the system’s “wants” directory so the service starts automatically at boot, but it doesn’t start it right now unless combined with --now.

Q4: How do you check why a service failed to start?

  • Answer: I would use two primary commands:
    1. systemctl status <service>: Provides a quick summary and the last few log lines.
    2. journalctl -u <service> -xe: Shows detailed, expanded logs and errors specifically for that unit.

Q5: What are “Targets” in systemd?

  • Answer: Targets are similar to “Runlevels” in older SysVinit systems. They represent a state of the system.
    • multi-user.target: Normal server operation (CLI).
    • graphical.target: Desktop environment.
    • rescue.target: Single-user mode for repairs.

Practical Management & Troubleshooting

Q6: You changed a configuration file for Nginx. How do you apply the changes without dropping current user connections?

  • Answer: Instead of restart, I would use sudo systemctl reload nginx.
    • Restart kills the process and starts a new one (downtime).
    • Reload instructs the daemon to re-read its config file while keeping the process running (no downtime).

Q7: How do you find all services that are currently “enabled” but not “running”?

  • Answer: You can use the list-units command with filters: systemctl list-units --type=service --state=inactive (Then cross-reference with list-unit-files to check the enabled status).

Q8: What is a “Zombie” process, and can you “kill” it?

  • Answer: A zombie process is a process that has finished execution but still has an entry in the process table because its parent hasn’t read its exit status yet. You cannot “kill” a zombie because it is already dead. To remove it, you must kill the parent process or signal the parent to “reap” its child.

Also read about Types Of Services In Linux: Popular Services And Management

Automation and Logs

Q9: Where are systemd unit files usually stored?

  • Answer:
  • /lib/systemd/system/: Default files installed by the OS/Packages.
    • /etc/systemd/system/: Custom unit files created by the administrator (takes priority).

Q10: How can you limit a service’s CPU or Memory usage using systemd?

  • Answer: By editing the [Service] section of the unit file (or using systemctl edit) and adding:
    • MemoryLimit=500M
    • CPUQuota=20% This utilizes Linux Cgroups (Control Groups) to throttle the service.
ScenarioCommand to Use
Service won’t stay runningjournalctl -u <service> -f
Need to start service at bootsudo systemctl enable <service>
Check system boot time/speedsystemd-analyze blame
List all running servicessystemctl list-units --type=service
Temporarily stop a servicesudo systemctl stop <service>

SysVinit and systemd

One of the biggest architectural changes in Linux history was the switch from SysVinit to systemd. They illustrate two entirely distinct approaches to system administration, even though they both function as the “Init” system (the first process that begins, PID 1).

SysVinit: The Traditionalist (Sequential)

The traditional Unix-style initialization system is called SysVinit (System V Init). Its foundation lies on the concept of Runlevels, which are numbered states (0–6) that specify the functions of the system (e.g., Runlevel 3 is multi-user CLI, while Runlevel 5 is GUI).

  • It operates by using a set of shell scripts found in /etc/init.d/, which are executed one by one by the system at bootup.
  • The “Wait Your Turn” Issue: SysVinit waits for Service A to finish entirely before even glancing at Service B if Service A must start before Service B. The entire boot process pauses and waits if a script hangs or takes a long time (such as a slow network mount).

Systemd: The Modernist (Parallel)

Systemd was created to address SysVinit’s bottlenecks. Rather than being merely an init system, it is a complete “system and service manager.” It substituted Targets (like multi-user.target) for runlevels.

  • How it operates: Unit Files (.service,.target, and.mount) are used in place of shell scripts. Instead of instructing systemd on how to script the service, these declarative text files describe it.
  • Systemd employs parallelism via using “Socket Activation.” All of the sockets for every service are created simultaneously. The sockets allow services to start at the same time. Instead of waiting for the process to be “ready,” Service B just waits for the data to show up on the socket if Service A is required.

SysVinit vs systemd

FeatureSysVinitsystemd
Boot SpeedSlowFast
Dependency HandlingManualAutomatic
LoggingSeparateIntegrated
Parallel StartupNoYes

Also read about Linux Networking Commands Interview Questions And Answers

Hemavathi
Hemavathihttps://govindhtech.com/
Myself Hemavathi graduated in 2018, working as Content writer at Govindtech Solutions. Passionate at Tech News & latest technologies. Desire to improve skills in Tech writing.
Index