QA
Intermediate LevelLinux Commands & SysAdmin

How do you create a custom systemd service unit file (/etc/systemd/system/myapp.service)?

❓ Interview Prompt: Explain systemd unit files, [Unit], [Service] (ExecStart, Restart=always, User, EnvironmentFile), [Install], and daemon-reload.

Custom background daemons are managed by creating a systemd unit file in '/etc/systemd/system/myapp.service':

Key Sections:

•
[Unit]: Description and dependencies ('After=network.target').
•
[Service]: Execution path ('ExecStart'), service user ('User=deploy'), environment variables, and auto-restart policy ('Restart=always').
•
[Install]: Boot target ('WantedBy=multi-user.target').

Code Implementation Example

ini
# /etc/systemd/system/node-app.service
[Unit]
Description=Node.js API Application
After=network.target postgresql.service

[Service]
Type=simple
User=deploy
WorkingDirectory=/var/www/node-app
ExecStart=/usr/bin/node server.js
Restart=always
RestartSec=5
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target
💡Custom systemd service unit file configuration for background Node.js application.
🎯 Interview Key Takeaway

Create systemd service unit files under /etc/systemd/system/ and run systemctl daemon-reload to manage custom background daemons.

#systemd#Service Unit#sysadmin#Intermediate
Back to all Linux Commands & SysAdmin Questions→

More Linux Commands & SysAdmin Interview Questions

Beginner LevelLinux Commands & SysAdmin

How do Linux File Permissions (chmod, chown, chgrp) work in Octal and Symbolic notation?

Beginner LevelLinux Commands & SysAdmin

What is the Linux Filesystem Hierarchy Standard (/bin, /etc, /var, /usr, /opt, /tmp)?

Beginner LevelLinux Commands & SysAdmin

What are File Descriptors (0=stdin, 1=stdout, 2=stderr) and Redirection (>, >>, 2>&1)?