RHEL7 환경에서 runlevel 변경하기 (inittab 3)
현재 runlevel 체크 하기
systemctl get-default
runlevel5.target
변경 가능한 target 목록 확인 하기
# systemctl list-units –type=target
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
cryptsetup.target loaded active active Encrypted Volumes
getty.target loaded active active Login Prompts
graphical.target loaded active active Graphical Interface
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target loaded active active Local File Systems
multi-user.target loaded active active Multi-User System
network.target loaded active active Network
nfs.target loaded active active Network File System Server
paths.target loaded active active Paths
remote-fs.target loaded active active Remote File Systems
slices.target loaded active active Slices
sockets.target loaded active active Sockets
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
timers.target loaded active active Timers
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
runlevel 3 로 변경하기
# systemctl set-default multi-user.target
변경 내용 확인하기
# systemctl get-default
multi-user.target
runlevel 을 변경하는 또 다른 방법은 systemd 가 제어하는 파일을 직접 조정하는 방법이다.
systemd 의 주요 target 은 /usr/lib/systemd/system 밑에 파일로 존재한다.
기본 runlevel 에 대한 적용 파일 위치는 /etc/systemd/system/default.target 링크 파일이다.
실제 /usr/lib/systemd/system 밑에 있는 runlevel 관련 target 파일을 /etc/systemd/system/default.target
파일로 link 해 주고 reboot 하면 변경이 된다.
rm ‘/etc/systemd/system/default.target’
ln -s ‘/usr/lib/systemd/system/multi-user.target’ ‘/etc/systemd/system/default.target’
# systemctl get-default
multi-user.target
runlevel 관련 target 파일 확인
# ls /lib/systemd/system/runlevel*target -l
lrwxrwxrwx. 1 root root 15 Aug 3 13:44 /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 13 Aug 3 13:44 /lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx. 1 root root 17 Aug 3 13:44 /lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Aug 3 13:44 /lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Aug 3 13:44 /lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx. 1 root root 16 Aug 3 13:44 /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx. 1 root root 13 Aug 3 13:44 /lib/systemd/system/runlevel6.target -> reboot.target
runleve 5 로 변경하기
ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target
or
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
이제 reboot 하면 최종 적용 된다.