운영중입니다

Linux 서비스 자동실행(enable) 설정 방법 정리 본문

리눅스

Linux 서비스 자동실행(enable) 설정 방법 정리

https443 2026. 5. 17. 21:23

리눅스 서버를 운영하다 보면 서비스(Service)를 재부팅 후에도 자동으로 실행되도록 설정해야 하는 경우가 많습니다.

하지만 사용하는 OS 버전에 따라 설정 방식과 명령어가 서로 다릅니다.

예를 들

  • CentOS 5/6 → SysVinit
  • CentOS 7 / Ubuntu → systemd

기반으로 나뉘기 때문에 명령어 차이를 알고 있어야 운영 시 혼동이 줄어듭니다.
해당 글에선 OS 별로 설정 방법에 대해 서술합니다.


1. Linux 서비스 자동실행(enable) 설정 방법 정리

(CentOS 5/6/7 + Ubuntu 비교)

리눅스에서 서비스(Service)를 부팅 시 자동 실행되도록 설정하는 방법은 OS 버전에 따라 사용하는 명령어가 다릅니다.

 

OS 버전 관리 시스템 사용 명령어
CentOS 5/6 SysVinit chkconfig
CentOS 7 systemd systemctl enable
Ubuntu (16.04 이상) systemd systemctl enable

 

2. 예시

centos7, apache 예시

#자동실행 설정
systemctl enable httpd

#자동실행 해제
systemctl disable httpd

#현재 자동 실행 여부 확인
systemctl is-enabled httpd
systemctl list-unit-files --type=service | grep httpd

# 전체 서비스 확인
systemctl list-unit-files --type=service

# 서비스 상태 확인
systemctl status httpd

#CentOS 5 / CentOS 6 (chkconfig 방식)
#CentOS 5, 6은 SysVinit 기반이며 chkconfig 명령어를 사용합니다.

#🔹 자동 실행 설정
chkconfig httpd on

#🔹 자동 실행 해제
chkconfig httpd off

#🔹 자동 실행 여부 확인
chkconfig --list httpd

#출력 예:
httpd  0:off 1:off 2:on 3:on 4:on 5:on 6:off
#3, 5 레벨이 on이면 일반 부팅 시 자동 실행됩니다.


#🔹 서비스 실행/중지
service httpd start
service httpd stop
service httpd restart

#Ubuntu (systemd 방식)

#Ubuntu 16.04 이상은 systemd 기반이므로 CentOS 7과 동일하게 systemctl을 사용합니다.

🔹 자동 실행 설정
systemctl enable apache2

#Ubuntu는 패키지명이 다를 수 있습니다.

예: Apache → apache2

#🔹 자동 실행 해제
systemctl disable apache2

#🔹 자동 실행 여부 확인
systemctl is-enabled apache2

3. 버전별 명령어 비교 요약

작업 CentOS 5/6 CentOS 7 Ubuntu
자동실행 설정 chkconfig httpd on systemctl enable httpd systemctl enable apache2
자동실행 해제 chkconfig httpd off systemctl disable httpd systemctl disable apache2
상태 확인 chkconfig --list systemctl is-enabled systemctl is-enabled
서비스 실행 service httpd start systemctl start httpd systemctl start apache2

 


4. 마무리

 

 

Linux 서버는 OS 버전에 따라 서비스 관리 방식이 다릅니다.

특히:

  • CentOS 5/6 → chkconfig
  • CentOS 7 이상 → systemctl

차이를 알고 있으면 운영 중 명령어 혼동을 줄일 수 있습니다.
실무에서는 Apache(httpd), MySQL(MariaDB), Redis 등의 자동 실행 설정 시 자주 사용하는 명령어입니다.