Managing Services with systemctl
Full-Access Members Only
Sorry, this lesson is only available to Server Academy Full-Access members. Become a Full-Access member now and get instant access to this and many more premium courses. Click the button below and get instant access now.
There are no resources for this lesson.
In this lesson, you will learn how to manage system services in Linux using
systemctl, a command-line utility for controlling the systemd system and service manager. Our focus will be on managing NGINX, a popular web server and reverse proxy service, using systemd.
By the end of this lesson, you will understand how to:
- Start, stop, and restart the NGINX service.
- Enable and disable NGINX to start on boot.
- Check the status of NGINX.
- Reload NGINX configurations.
Starting, Stopping, and Restarting NGINX
To start the NGINX service immediately:
sudo systemctl start nginx
To stop the NGINX service:
sudo systemctl stop nginx
To restart the NGINX service (useful for reloading it with the latest configuration):
sudo systemctl restart nginx
Enabling and Disabling NGINX
To enable NGINX to start automatically at boot:
sudo systemctl enable nginx
To prevent NGINX from starting automatically at boot:
sudo systemctl disable nginx
Checking the Status of NGINX
To check the status of NGINX, including whether it is active, enabled, and its recent logs:
sudo systemctl status nginx
Reloading NGINX Configurations
If you've made configuration changes to NGINX and you don't want to restart the service completely, you can reload the configuration:
sudo systemctl reload nginx
Managing All Services
To list all services that systemd knows about, whether active or not:
sudo systemctl list-unit-files --type=service
- Always check the status of NGINX after starting, stopping, or restarting to ensure it's in the desired state.
- When enabling or disabling services like NGINX, consider the impact on the system's performance and boot time.
- Use the reload function judiciously to apply configuration updates to NGINX without disrupting the service.
systemctl is a powerful tool that provides comprehensive control over services in Linux systems using systemd. Understanding how to manage services like NGINX with
systemctl is essential for system administrators and users who want to ensure their web services are running efficiently and securely. That is all you need to learn in this lesson! See you in the next one.
Server Academy Members Only
Sorry, this lesson is only available to Server Academy Full Access members. Become a Full-Access Member now and you’ll get instant access to all of our courses.