CentOS7 Runlevel 변경하기

System Story/CentOS 7 2015. 1. 2. 10:24

CentOS7 (Redhat 7) 버전부터 시스템 Run Level을 변경하는 방법이 바뀌었다.

 

기존 CentOS6 버전까지는 아래와 같이 /etc/inittab 파일이하 id 값만 변경하면 시스템 Runlevel이 변경되었다.

 

[root@CentOS6 ~]#
[root@CentOS6 ~]# cat /etc/inittab
#
# inittab       This file describes how the INIT process should set up
#               the system in a certain run-level.
#
# Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
#               Modified for RHS Linux by Marc Ewing and Donnie Barnes
#

# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6

# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now

 

... 중략

 

 

하지만 CentOS7 버전 부터는 systemctl 명령을 통해 Runlevel을 변경하도록 안내해 주고 있다.

 

[root@localhost ~]#
[root@localhost ~]# cat /etc/inittab
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /etc/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To set a default target, run:
#
# ln -sf /lib/systemd/system/<target name>.target /etc/systemd/system/default.target
#
[root@localhost ~]#

 

 

1. 현재 시스템 Run Level 확인하기

 

[root@localhost ~]#
[root@localhost ~]# systemctl get-default
graphical.target
[root@localhost ~]#

 

 

2. System booting 시 Level을 Runlevel 3로 변경하기

 

[root@localhost ~]#
[root@localhost ~]# systemctl set-default multi-user.target
rm '/etc/systemd/system/default.target'
ln -s '/usr/lib/systemd/system/multi-user.target' '/etc/systemd/system/default.target'
[root@localhost ~]#
[root@localhost ~]#

 

 

3. 현재 Level을 바로 변경 하기 (init 3)

 

[root@localhost ~]#
[root@localhost ~]# systemctl isolate multi-user.target
[root@localhost ~]#

 

 

 

Trackbacks 0 : Comments 0

Write a comment