最近在用Windows 连接 Ubuntu的PC时想使用下图形化界面,因为之前玩树莓派用过VNC因此将为PC安装VNC 来进行图形传输。
准备工作:
windows安装VNC-Viewer 或者相关工具,Linux 安装vncserver.
1.安装
1.1更新源和系统
apt update
apt upgrade -y
1.2安装桌面
mate 桌面较为精简且不会出现显示不全的问题,选择其中一个安装即可。
apt install ubuntu-desktop, gnome-panel # Gnome桌面
apt install kubuntu-full # KDE桌面
# Mate桌面 (推荐)
# 仅安装核心组件
apt install ntp
apt install ubuntu-mate-core
# 完整安装
apt install ubuntu-mate-core ubuntu-mate-desktop
2.基本操作
安装 VNC server
apt install vnc4server -y
第一次启动需要配置密码
vncserver (或vnc4server)
打开会话
vncserver :1
关闭会话
vncserver -kill :1
设置分辨率
vncserver -geometry 1920x1080 :1
3.文件配置
vim /root/.vnc
添加配置:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
# x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
mate-session &
其他桌面配置:
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
#4.开机启动
首先输入 crontab 命令,显示如下:
Select an editor. To change later, run ‘select-editor’.
1. /bin/ed
2. /bin/nano <---- easiest 3. /usr/bin/vim.basic 4. /usr/bin/vim.tiny Choose 1-4 [2]:
在末尾添加命令,设置开机启动
@reboot /usr/bin/vncserver :1
重启服务
reboot