CentOS6 でランレベルを変更する場合は、/etc/inittab を編集すればよかったのですが、CentOS7 では inittab を使用しません。
CentOS7 の inittab は以下の内容になっています。
# 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 #CentOS7 では、/etc/systemd/system/default.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 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 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. 14 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'.現在の設定を確認します。
# systemctl get-default multi-user.target # ls -l /etc/systemd/system/default.target lrwxrwxrwx. 1 root root 37 9月 16 22:21 /etc/systemd/system/default.target -> /lib/systemd/system/multi-user.targetmulti-user.target は、ランレベル3 (マルチユーザ・コンソールログイン) に該当します。
ランレベルを、5 (グラフィカルログイン)に変更します。
# systemctl set-default graphical.target rm '/etc/systemd/system/default.target' ln -s '/usr/lib/systemd/system/graphical.target' '/etc/systemd/system/default.target'設定を確認します。
# systemctl get-default graphical.targetあとは、リブートすれば、設定変更が有効になります。
■ 補足
root のパスワードを忘れた場合に、シングルユーザモードになって、rootユーザのパスワードを再設定したいときは、以下のサイトが参考になります。