Linux Terminal Command: systemctl
The systemctl command is an essential tool in System Services & Scheduling. In this tutorial, we will explore what systemctl does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.
Concept & Explanation
The systemctl command manages system services, checking status, enabling boot logs, and restarting daemons under systemd.
Common Options & Syntax
systemctl [options] [arguments]
Here are the most common flags used with systemctl:
- Simple Usage: Basic default commands.
- Detailed View: Shows diagnostic information.
- Advanced Actions: Can chain parameters for scripting.
1. Interactive Example (Simple)
Here is how most people run the command:
# Example
systemctl status nginx
What it does: Displays the active status and recent log lines of the Nginx service.
2. Power-User Example (Advanced)
For scripting and advanced diagnostics, use this configuration:
# Advanced
sudo systemctl enable nginx && sudo systemctl restart nginx
What it does: Configures Nginx to start automatically on system boot and restarts the active service instance.
⚙️ Warning & Common Pitfalls
[!WARNING] Do not confuse
serviceandsystemctl. Whileserviceworks on SysVinit systems,systemctlis the standard control tool on systemd platforms.
🔗 Related Commands
Here are some related posts on cli_tty1 you might want to check out:
- journalctl : Query the systemd journal logs database.
- cron : Daemon to execute scheduled commands.
- at : Queue, examine or delete jobs for later execution (one-off).