Ubuntu下使用SSH和遠程桌面使用很方便,使用遠程桌面就要使用到vnc4server
首先安裝程序
[email protected]:$ sudo apt-get install vnc4server
再修改vnc password
[email protected]:$ vncpasswd
Password: ******
Verify:*****
啟動
[email protected]:$ vncserver
New 'cuile-Dell-E521:1 (cuile)' desktop is cuile-Dell-E521:1
Starting applications specified in /home/cuile/.vnc/xstartup
Log file is /home/cuile/.vnc/cuile-Dell-E521:1.log
默認的界面並不好看,很丑,需要修改一下配置文件
[email protected]:$ vim .vnc/xstartup
#!/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"
&
x-window-manager &
修改成這個樣子
#!/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" &
#x-window-manager &
這裡算是完成了vncserver的初步配置
修改xinitrc文件的權限,要不打開的桌面會是一面花
$ sudo
chmod
755
/
etc/
X11/
xinit/
xinitrc關閉遠程桌面
[email protected]:$ vncserver -kill :1
這裡要注意“-kill :1”,kill後面有一個空格,這個不能少,少了結果就不一樣了
“1”是指打開vnc時使用的屏幕號“New ‘cuile-Dell-E521:1 (cuile)’ desktop is cuile-Dell-E521:1”,看到這裡的“cuile-Dell-E521:1”了吧
[email protected]:$ vncserver -kill :1
Killing Xvnc4 process ID 1591
出現上面的結果就說明已經關掉vnc了
定制遠程桌面大小
[email protected]:$ vncserver -geometry 1366x768
這樣vnc就會啟動一個1366×768大小的遠程屏幕
加入啟動服務
ubuntu 10.10 下無法加入啟動服務,試過了網上的所有方法沒有一個可行的
想可能的原因是在Ubuntu下安裝的vnc設置都保存在用戶目錄下了,沒有放在一個統一的位置下,所以在用戶登錄前系統不能從用戶目錄下取得設置文件
這種模式比Ubuntu自帶的vino要好多了,居然都要手工啟動,但vino必須在本機圖形界面登錄的情況下才可以用,跟windows下的模式非常非常像,簡直一模一樣,如果機器重啟了還需要重新的登錄一下,比較麻煩。
而vncserver就好很多,雖然也要手功,但不用本機圖形界面登錄,不需要屏幕、鍵盤、鼠標,只能遠程ssh上去就可以打開了。
沒有試過Ubuntu 10.10 Server版,Server版應該支持vncserver的自啟動吧。