CentOS7.x命令⾏下安装图形化界⾯
1. 安装组件包,时间略长,请耐⼼等待。
0 16:36:25 root@cytemp,172.16.15.2:~ # yum -y groupinstall "GNOME Desktop" "Graphical Administration Tools"
2. 修改系统默认启动⽅式。
# 默认是启动命令⾏界⾯。
0 16:42:23 root@cytemp,172.16.15.2:~ # ll /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 37 2⽉ 25 02:11 /etc/systemd/system/default.target -> /lib/systemd/system/multi-user.target
# 修改为默认启动图形化界⾯。
0 16:45:25 root@cytemp,172.16.15.2:~ # ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target
0 16:58:56 root@cytemp,172.16.15.2:~ # shutdown -r now
centos vim命令3. 扩展:安装vncserver。
0 17:03:39 root@cytemp,172.16.15.2:~ # yum -y install tigervnc-server
0 17:03:57 root@cytemp,172.16.15.2:~ # cd /etc/systemd/system
0 17:04:02 root@cytemp,172.16.15.2:/etc/systemd/system # cp /lib/systemd/system/vncserver@.service ./vncserver@:1.service
0 17:04:43 root@cytemp,172.16.15.2:/etc/systemd/system # vim vncserver@\:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=simple
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver_wrapper root %i
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
# 需要先设置VNC密码才能启动,普通⽤户需要切到普通⽤户下才能设置VNC密码。
0 17:06:59 root@cytemp,172.16.15.2:/etc/systemd/system # vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
0 17:06:00 root@cytemp,172.16.15.2:/etc/systemd/system # systemctl daemon-reload
----------------------------------------------------------------------------------------------------------------
# 如果显⽰不全⾯则需要修改分辨率
vim /usr/bin/vncserver
$geometry = "2560x1440"; # 修改为实际显⽰器分辨率即可
----------------------------------------------------------------------------------------------------------------
0 17:07:19 root@cytemp,172.16.15.2:/etc/systemd/system # systemctl start vncserver@:1.service
# VNC默认以5901为第⼀个端⼝,多⽤户使⽤时,端⼝顺序分配。
0 17:07:20 root@cytemp,172.16.15.2:/etc/systemd/system # ps -ef | grep -i vnc
root 8255 1 0 17:07 ? 00:00:00 /bin/sh /usr/bin/vncserver_wrapper root :1
root 8295 1 0 17:07 ? 00:00:00 /usr/bin/Xvnc :1 -auth /root/.Xauthority -desktop trainee2:1 (r
oot) -fp catalogue:/etc/X11/fontpath.d -geometry 2560x1440 -pn -rfbauth /root/.vnc/passwd -rfbport 5901 -rfbwait 30000 root 8319 1 0 17:07 ? 00:00:00 /bin/sh /root/.vnc/xstartup
root 9134 2214 0 17:07 pts/0 00:00:00 grep --color=auto vnc
# 多⽤户使⽤VNC
0 17:07:22 root@cytemp,172.16.15.2:/etc/systemd/system # cp vncserver@\:1.service vncserver@\:2.service
0 17:10:34 root@cytemp,172.16.15.2:/etc/systemd/system # sed -i 's/root/liuhuan/g' vncserver@\:2.service
0 17:10:49 root@cytemp,172.16.15.2:/etc/systemd/system # su - liuhuan
上⼀次登录:四 4⽉ 15 15:04:01 CST 2021从 101.228.245.134pts/4 上
0 17:11:09 liuhuan@cytemp,172.16.15.2:~ $ vncpasswd
0 17:11:26 liuhuan@cytemp,172.16.15.2:~ $ 登出
0 17:11:27 root@cytemp,172.16.15.2:/etc/systemd/system # systemctl daemon-reload
0 17:12:37 root@cytemp,172.16.15.2:/etc/systemd/system # systemctl start vncserver@\:2.service
# 有防⽕墙的话,将对应启动的端⼝开放出去(⽐如上例将liuhuan的5902端⼝开放),就可以使⽤VNC连接了。
写作不易,转载请注明出处,谢谢~~
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论