Gestione dei servizi: `systemctl` (systemd)
Controlli e gestisca i servizi e i daemon di sistema usando il comando `systemctl`.
Gestione dei servizi: `systemctl` (systemd) è una lezione Linux Command Line Mastery gratuita su CoddyKit. Questa è la lezione 2 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Linux Command Line Mastery, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Linux Command Line Mastery include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
What are System Services?
On Linux, many programs run silently in the background to perform essential tasks. These are called services or daemons.
Think of them as silent helpers: a web server, a database, or even your Wi-Fi manager. They often start automatically when your system boots.
Meet systemd
systemd is the initialization system used by most modern Linux distributions (like Ubuntu, Fedora, CentOS).
It's responsible for managing services and processes from boot-up to shut-down, ensuring everything starts and stops in the correct order.
Your Tool: systemctl
To interact with systemd and manage these services, we use the powerful systemctl command.
It's your primary interface for checking status, starting, stopping, enabling, and disabling services on your system.
Check Service Status
The first step is often checking if a service is running. Use systemctl status <service_name>.
Let's check the status of the SSH daemon (sshd), which allows secure remote access to your machine.
systemctl status sshdStarting a Service
If a service isn't running or you've stopped it, you can start it with systemctl start <service_name>.
This command attempts to begin the service immediately. You'll often need root privileges (using sudo) for most system services.
sudo systemctl start sshdStopping a Service
To halt a running service, use systemctl stop <service_name>.
This is useful if you need to perform maintenance or reconfigure a service. Be cautious, as stopping critical services can affect system functionality.
sudo systemctl stop sshdRestart vs. Reload
Restarting (systemctl restart <service>) fully stops and then starts a service. This is often needed after major configuration changes.
Reloading (systemctl reload <service>) tells a service to re-read its configuration without a full restart, minimizing downtime. Not all services support reload.
sudo systemctl restart sshdManaging Autostart
Services can be set to start automatically at boot. This is called enabling the service.
sudo systemctl enable <service>: Configures a service to start on boot.sudo systemctl disable <service>: Prevents a service from starting on boot.
These commands only modify boot behavior; they don't start/stop the service immediately.
sudo systemctl enable sshdListing All Services
To see a list of all loaded services and their current status (active, inactive, enabled, disabled), use systemctl list-units --type=service --all.
This command provides a comprehensive overview of what's configured on your system.
systemctl list-units --type=service --allQuick Check: Service Control
Which command would you use to prevent the apache2 web server service from starting automatically when your Linux system boots up?
Recap: Service Management
You've learned how to manage system services using the powerful systemctl command!
- Use
statusto check a service's state. start,stop,restartto control running services.enableanddisableto manage boot-time behavior.list-units --type=service --allto view all services.
Mastering systemctl is crucial for effective Linux system administration.
Domande Frequenti
La lezione «Gestione dei servizi: `systemctl` (systemd)» è gratuita?
Sì — il testo completo di «Gestione dei servizi: `systemctl` (systemd)» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Linux Command Line Mastery, passa a CoddyKit PRO. Il corso Linux Command Line Mastery include 4 lezioni in totale.
Cosa imparerò in «Gestione dei servizi: `systemctl` (systemd)»?
Controlli e gestisca i servizi e i daemon di sistema usando il comando `systemctl`. Eserciti Linux Command Line Mastery con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Linux Command Line Mastery?
Non è richiesta alcuna esperienza precedente. Linux Command Line Mastery su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 2 di 4.
Quanto tempo richiede la lezione «Gestione dei servizi: `systemctl` (systemd)»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Linux Command Line Mastery?
Sì. Ogni lezione Linux Command Line Mastery include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Pianificazione dei job: `cron` e `at`
- Gestione dei servizi: `systemctl` (systemd)
- Automatizzare le attività con le funzioni shell
- Logging centralizzato e rotazione con journald e logrotate