Управление службами: `systemctl` (systemd)
Управляйте системными службами и фоновыми процессами с помощью команды `systemctl`.
«Управление службами: `systemctl` (systemd)» — бесплатный урок Linux Command Line Mastery на CoddyKit. Это урок 2 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения Linux Command Line Mastery, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс Linux Command Line Mastery содержит 4 уроков всего.
Части этого урока еще не переведены и отображаются на английском.
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.
Часто задаваемые вопросы
Урок «Управление службами: `systemctl` (systemd)» бесплатный?
Да — полный текст урока «Управление службами: `systemctl` (systemd)» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс Linux Command Line Mastery, подпишись на CoddyKit PRO. Курс Linux Command Line Mastery содержит 4 уроков всего.
Чему я научусь в уроке «Управление службами: `systemctl` (systemd)»?
Управляйте системными службами и фоновыми процессами с помощью команды `systemctl`. Ты практикуешь Linux Command Line Mastery с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.
Нужен ли мне опыт, чтобы начать Linux Command Line Mastery?
Предыдущий опыт не требуется. Linux Command Line Mastery на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 2 из 4.
Сколько времени занимает урок «Управление службами: `systemctl` (systemd)»?
Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.
Можно ли писать и запускать код в этом уроке Linux Command Line Mastery?
Да. Каждый урок Linux Command Line Mastery включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.
Все уроки этого курса
- Планирование заданий: `cron` и `at`
- Управление службами: `systemctl` (systemd)
- Автоматизация задач с помощью функций оболочки
- Централизованное журналирование и ротация с journald и logrotate