CentOS 7.2 安装 GNOME 桌面环境

我安装的 CentOS 7.2是一个最小版本的 CentOS-7-x86_64-Minimal-1511.iso,不带桌面环境,需要手动安装,我通过 yum 安装 GNOME Desktop 后不会自动切换到桌面环境,每次需要执行 startx
后来参考 CentOS-7 “Minimal Desktop” installation GNOMEInstall Gnome GUI on CentOS 7 / RHEL 7 解决,解决方案说明如下:

1
2
In CentOS 7, systemd uses ‘targets’ instead of runlevels; /etc/inittab file is no more used to change run levels. Issue the following command to enable the GUI on system start.
# ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

相关操作记录如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
[root@CentOS72 ~]# yum group list
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.pubyun.com
* extras: mirrors.sina.cn
* updates: mirrors.pubyun.com
Installed Environment Groups:
GNOME Desktop
Available Environment Groups:
Minimal Install
Compute Node
Infrastructure Server
File and Print Server
Basic Web Server
Virtualization Host
Server with GUI
KDE Plasma Workspaces
Development and Creative Workstation
Available Groups:
Compatibility Libraries
Console Internet Tools
Development Tools
Graphical Administration Tools
Legacy UNIX Compatibility
Scientific Support
Security Tools
Smart Card Support
System Administration Tools
System Management
Done
[root@CentOS72 ~]# yum groupinstall "GNOME Desktop"
[root@CentOS72 ~]# 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 /usr/lib/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 view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
#
[root@CentOS72 ~]# ls -l /lib/systemd/system/runlevel*.target
lrwxrwxrwx. 1 root root 15 May 8 15:20 /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 13 May 8 15:20 /lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx. 1 root root 17 May 8 15:20 /lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 May 8 15:20 /lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 May 8 15:20 /lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx. 1 root root 16 May 8 15:20 /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx. 1 root root 13 May 8 15:20 /lib/systemd/system/runlevel6.target -> reboot.target
[root@CentOS72 ~]# cat /lib/systemd/system/graphical.target
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Graphical Interface
Documentation=man:systemd.special(7)
Requires=multi-user.target
Wants=display-manager.service
Conflicts=rescue.service rescue.target
After=multi-user.target rescue.service rescue.target display-manager.service
AllowIsolate=yes
[root@CentOS72 ~]# ls -l /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 37 Feb 12 11:12 /etc/systemd/system/default.target -> /lib/systemd/system/multi-user.target
[root@CentOS72 ~]# unlink /etc/systemd/system/default.target
[root@CentOS72 ~]# ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
[root@CentOS72 ~]# reboot

EOF