Skip to content
Search RunEntLinux

Searches general documentation on RunEntLinux. Each distribution has its own documentation search.

    Browse this documentation

    Getting Started with systemctl

    systemd is the default init system and service manager for all EL systems since CentOS 7, including AlmaLinux and Rocky Linux. It replaces the traditional SysVinit and is responsible for bootstrapping the system, managing services, mounting filesystems, and other core tasks. systemctl is the primary command-line tool for interacting with systemd.

    systemd manages system resources around the core concept of units. Common unit types include:

    Unit TypeSuffixDescription
    Service.serviceSystem services (e.g., Nginx, sshd)
    Socket.socketInter-process communication sockets
    Target.targetA collection of units, similar to runlevels
    Timer.timerScheduled task triggers
    Mount.mountFilesystem mount points

    systemd unit configuration files are typically stored in the following locations:

    • /usr/lib/systemd/system/ — Unit files installed by packages
    • /etc/systemd/system/ — Administrator-customized or overridden unit files (higher priority)
    Start the Nginx service
    sudo systemctl start nginx
    Stop the Nginx service
    sudo systemctl stop nginx

    Restarting stops and then starts the service, suitable for scenarios where a full reload is needed after configuration changes:

    Restart the Nginx service
    sudo systemctl restart nginx

    Some services support reloading their configuration without interrupting operation:

    Reload Nginx configuration (without interrupting the service)
    sudo systemctl reload nginx

    If you are unsure whether a service supports reload, you can use reload-or-restart, which attempts reload first and falls back to restart if it fails:

    Try reload, fall back to restart if unsupported
    sudo systemctl reload-or-restart nginx

    The status subcommand displays the service’s running state, PID, memory usage, and recent log output:

    Check Nginx service status
    sudo systemctl status nginx

    Example output:

    ● nginx.service - The nginx HTTP and reverse proxy server
    Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: disabled)
    Active: active (running) since Tue 2026-03-24 10:15:30 CST; 2h ago
    Main PID: 1234 (nginx)
    Tasks: 3 (limit: 23456)
    Memory: 5.2M
    CPU: 35ms
    CGroup: /system.slice/nginx.service
    ├─1234 "nginx: master process /usr/sbin/nginx"
    └─1235 "nginx: worker process"

    You can also use the following commands to quickly check service status:

    Check if a service is running
    systemctl is-active nginx
    Check if a service is enabled for boot
    systemctl is-enabled nginx
    Check if a service has failed
    systemctl is-failed nginx
    Set Nginx to start automatically at boot
    sudo systemctl enable nginx

    This creates a symbolic link under /etc/systemd/system/ so the service starts automatically when the system boots.

    If you want to enable and start the service immediately, add the --now flag:

    Enable at boot and start immediately
    sudo systemctl enable --now nginx
    Disable Nginx from starting at boot
    sudo systemctl disable nginx

    This also supports --now to stop the service at the same time:

    Disable at boot and stop immediately
    sudo systemctl disable --now nginx
    List all active service units
    systemctl list-units --type=service

    List All Installed Services (Including Inactive)

    Section titled “List All Installed Services (Including Inactive)”
    List all installed service unit files
    systemctl list-unit-files --type=service
    View all failed units
    systemctl --failed
    View the dependency tree of Nginx
    systemctl list-dependencies nginx

    systemd collects all service logs through journald. You can use journalctl to quickly view a service’s log output:

    View all logs for the Nginx service
    sudo journalctl -u nginx
    Follow Nginx log output in real time
    sudo journalctl -u nginx -f
    View Nginx logs since the current boot
    sudo journalctl -u nginx -b

    For more advanced journalctl usage, see the Journal Logs chapter.

    systemd uses targets to replace traditional runlevels. Common targets and their correspondences:

    TargetTraditional RunlevelDescription
    poweroff.target0Power off
    rescue.target1Single-user/rescue mode
    multi-user.target3Multi-user command-line mode
    graphical.target5Graphical interface mode
    reboot.target6Reboot
    View the current default boot target
    systemctl get-default
    Set the default boot target to multi-user command-line mode
    sudo systemctl set-default multi-user.target
    Temporarily switch to rescue mode (without changing the default target)
    sudo systemctl isolate rescue.target
    OperationCommand
    Start a servicesudo systemctl start <service>
    Stop a servicesudo systemctl stop <service>
    Restart a servicesudo systemctl restart <service>
    View statussudo systemctl status <service>
    Enable at bootsudo systemctl enable <service>
    Disable at bootsudo systemctl disable <service>
    Enable and startsudo systemctl enable --now <service>
    List all servicessystemctl list-units --type=service
    View failed unitssystemctl --failed
    View service logssudo journalctl -u <service>