fork() → exec()running, sleeping, stopped, zombieSCHED_FIFO, SCHED_RRps, top, htopread(), write()open()fork(), execve()straceCommands:
lsmod modprobe <module> rmmod <module>
/devsystemd (PID 1)View logs:
dmesg journalctl -k
Runtime config via sysctl
sysctl -a sysctl vm.swappiness=10
/proc and /sysCheck version:
uname -r
ip link, ip addrip link set eth0 up|downip addr add 192.168.1.10/24 dev eth0lo (127.0.0.1)/24 = 255.255.255.0ip routedefault via 192.168.1.1ip neighip route add 10.0.0.0/24 via 192.168.1.1ip route del …ip rule, multiple routing tables/etc/resolv.confdig, nslookup/etc/hostsresolvectl statusss -lntupnetstat -tulnpAllow port (iptables):
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -L -nUFW (simple):
ufw allow 80 ufw enable
ping 8.8.8.8traceroute, tracepathtcpdump -i eth0nc -zv host port, telnetip -s linkiftop, nloadss, lsof -iCheck service bind:
ss -lntp | grep 80
ip netns/etc/hosts/etc/resolv.conf/etc/network/interfaces (Debian legacy)/etc/netplan/*.yaml (Ubuntu)ip a ip r ss -tulnp ping dig tcpdump curl
systemd is the init system and service manager for modern Linux distributions.
It is responsible for:
It replaced SysVinit & Upstart in most distros (Ubuntu, RHEL, CentOS, Debian, Arch).
Old init systems:
systemd provides:
Everything in systemd is a unit.
A unit is a configuration file describing something systemd manages.
Common unit types:
| Unit Type | Purpose |
|---|---|
service | Daemons / background processes |
socket | Socket activation |
target | Group of units (like runlevels) |
mount | Mount points |
automount | On-demand mounts |
timer | Cron replacement |
path | File/directory watcher |
device | Hardware devices |
slice | Resource control (cgroups) |
scope | Externally created processes |
Example unit name:
nginx.service
Priority order:
/etc/systemd/system/ # Admin overrides (highest priority)
/run/systemd/system/ # Runtime units /lib/systemd/system/
# Distribution default units
Check PID 1:
ps -p 1 -o comm=
Targets replace SysV runlevels.
| Target | Equivalent |
|---|---|
poweroff.target | 0 |
rescue.target | 1 |
multi-user.target | 3 |
graphical.target | 5 |
reboot.target | 6 |
Default target:
systemctl get-default
Set default:
systemctl set-default multi-user.target
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
systemctl reload nginx
systemctl status nginx
Enable at boot:
systemctl enable nginx
Disable:
systemctl disable nginx
Example:
[Unit] Description=Nginx Web Server After=network.target
[Service] ExecStart=/usr/sbin/nginx -g 'daemon off;' Restart=always User=www-data
[Install] WantedBy=multi-user.target
Requires= → hard dependencyWants= → soft dependencyAfter= → start orderBefore= → inverse orderExample:
Requires=network.target After=network.target
systemd:
Benefits:
Example:
sshd.socket → sshd.service
Timer unit + service unit.
Example:
systemctl list-timers
Timer benefits over cron:
systemd logging is handled by journald.
View logs:
journalctl journalctl -u nginx journalctl -b journalctl -f
Persistent logs:
/var/log/journal/
systemd uses cgroups to:
Examples:
MemoryLimit=500M CPUQuota=50%
Check cgroups:
systemd-cgls
| Feature | SysVinit | systemd |
|---|---|---|
| Startup | Sequential | Parallel |
| Dependencies | Manual | Automatic |
| Supervision | ❌ | ✅ |
| Logging | syslog | journald |
| Resource control | ❌ | cgroups |
| Socket activation | ❌ | ✅ |
systemctl status <service> journalctl -xe systemctl list-units systemctl list-unit-files systemctl show <service>
| Component | Role |
|---|---|
systemd | PID 1 init |
systemctl | Control interface |
journald | Logging |
logind | User sessions |
udevd | Device manager |
timesyncd | Time sync |
resolved | DNS |
networkd | Network management |
systemd shows:
systemd is a dependency-aware, parallel init and service management system that controls how Linux boots, runs, logs, and manages resources.