systemctl
프로세스·시스템
쓰는 꼴
systemctl <verb> <unit>systemd 서비스를 켜고 끄고 상태를 봅니다 — `enable`은 부팅 때만 정하는 것이라 지금도 켜려면 `enable --now`이고, 유닛 파일을 고친 뒤에는 `daemon-reload`가 필요합니다.
자주 쓰는 옵션
| 옵션 | 뜻 |
|---|---|
| status <unit> | Whether it is running, its PID, and the last log lines. |
| start / stop / restart | Act on the service now, without changing boot behaviour. |
| reload | Re-read the config without dropping connections, if the service supports it. |
| enable --now <unit> | Start it now and also start it at every boot. |
| daemon-reload | Required after you edit a .service file, before restarting it. |
| list-units --failed | Everything that failed to start. |
| --user | Act on your own user units instead of the system ones. |
예시
sudo systemctl restart nginxRestart the web server.
systemctl status sshd --no-pagerPrint the state and recent log lines without opening a pager.
sudo systemctl enable --now dockerStart Docker and make it come back after a reboot.
무엇이 돌고 있고 무엇이 자원을 먹는지 봅니다. 죽이기 전에 무엇인지 확인하는 것이 순서입니다.
읽는 방법
- 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
- 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
- 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.
자주 묻는 것
Q. systemctl은 무엇을 하나요?
systemd 서비스를 켜고 끄고 상태를 봅니다 — `enable`은 부팅 때만 정하는 것이라 지금도 켜려면 `enable --now`이고, 유닛 파일을 고친 뒤에는 `daemon-reload`가 필요합니다.
Q. 어떻게 치나요?
systemctl <verb> <unit> — 대괄호는 생략할 수 있는 자리입니다.
Q. 옵션은 몇 개나 자주 쓰나요?
여기 정리한 것은 7개입니다. 전체 목록은 man systemctl에 있습니다. 이 명령은 프로세스·시스템 갈래입니다.
같이 보는 명령
man 페이지: man systemctl