x11vnc 對於Ubuntu15.04以後和Ubuntu14.04以前的配置和開機自啟
阿新 • • 發佈:2019-02-18
遠端桌面中x11vnc還是挺不錯的,速度還是挺好的,推薦使用x11vnc。x11vnc的配置教程網上挺多的了,但是大部分都是Ubuntu14.04以前的方法,而在Ubuntu15.04以後,自啟模式發生了變化,下面主要介紹一下兩種模式的差別。
下面的步驟是Ubuntu14.04和Ubuntu15.04共有的步驟:
1. 首先安裝x11vnc,這個可以直接使用命令安裝,如下:
sudo apt-get install x11vnc
安裝完後就可以手動啟動,命令如下:
2 .設定開機自啟sudo /usr/bin/x11vnc -display :0 -auth /var/run/lightdm/root/:0 -forever -bg -o /var/log/x11vnc.log -rfbauth /etc/x11vnc.pass -rfbport 5900
設定遠端登入的密碼
sudo x11vnc -storepasswd
輸入密碼後,命令會提示你是否儲存密碼到~/.vnc/passwd檔案裡,輸入y儲存密碼
設定x11vnc通用的密碼儲存位置
sudo x11vnc -storepasswd in /etc/x11vnc.pass
將使用者目錄下的passwd檔案內容複製到/etc/x11vnc.pass中
下面就是Ubuntu14.04以前和Ubuntu15.04以後得不同之處了。
Ubuntu14.04:
新建一個檔案,並開啟檔案
sudo gedit /etc/init/x11vnc.conf
複製下面的內容到檔案中:
然後儲存重啟就可以了,用vnc viewer遠端。start on login-session-start script x11vnc -display :0 -auth /var/run/lightdm/root/:0 -forever -bg -o /var/log/x11vnc.log -rfbauth /etc/x11vnc.pass -rfbport 5900 end script
Ubuntu15.04:
Ubuntu15.04以後得服務管理器已經切換到了systemd中,其系統服務指令碼目錄為:/lib/systemd/system/
所以要自動啟動x11vnc,需要在系統服務目錄中新建服務檔案
sudo vi /lib/systemd/system/x11vnc.service
拷貝下面的內容到檔案中:
然後以754的許可權儲存在根目錄:[Unit] Description=Start x11vnc at startup. After=multi-user.target [Service] Type=simple ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/USERNAME/.vnc/passwd -rfbport 5900 -shared [Install] WantedBy=multi-user.target
sudo chmod 774 /lib/systemd/system/x11vnc.service
然後再設定二開機自啟服務:
sudo systemctl enable x11vnc.service
下面給出幾個常用的設定命令
systemctl start nginx.service 啟動服務
systemctl enable nginx.service設定開機自啟動
systemctl disable nginx.service停止開機自啟動
systemctl disable nginx.service檢視服務當前狀態
systemctl status nginx.service檢視服務當前狀態
systemctl restart nginx.service重新啟動服務
systemctl list-units --type=service檢視所有已啟動的服務