如何在redhat 7上安裝VNC伺服器

2022-08-20 16:36:08 字數 3656 閱讀 1771

平時我們基本上都是用xshell或者用putty遠端我們的linux伺服器,如果我們的linux伺服器安裝了圖型化介面那我們又該如何遠端使用我們的圖形化介面呢?下面我們用vnc來實現遠端我們的linux伺服器

1:安裝vnc server:yum -y install vnc-server

2:複製vnc server的配置模板:cp  [email protected]   vncserver@:1

.service

[root@xwq

~]# cd /lib/systemd/system

[root@xwq system]# cp [email protected] vncserver@:

1.service

注:vnc 服務本身使用的是5900埠。鑑於有不同的使用者使用 vnc ,每個人的連線都會獲得不同的埠。配置檔名裡面的數字告訴 vnc 伺服器把服務執行在5900的子埠上。在我們這個例子裡,第乙個 vnc 服務會執行在5901(5900 + 1)埠上,之後的依次增加,執行在5900 + x 號埠上。其中 x 是指之後使用者的配置檔名 vncserver@:x.service 裡面的 x 。

如果要用更多的使用者連線,需要建立配置檔案和埠,新增乙個新的使用者和埠。你需要建立 vncserver@:2.service 並替換配置檔案裡的使用者名稱和之後步驟裡相應的檔名、埠號。請確保你登入 vnc 伺服器用的是你之前配置 vnc 密碼的時候使用的那個使用者名稱。

3:編輯配置模板:vim vncserver@:1

.service

把root使用者加入登陸使用者中,以及修改登陸後的vnc解析度

修改前:

[unit]

description

=remote desktop service (vnc)

after=syslog.target network.target

[service]

type=forking

# clean any existing files

in /tmp/.x11-unix environment

execstartpre=/bin/sh -c '

/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :

'execstart=/usr/sbin/runuser -l -c "

/usr/bin/vncserver %i

"pidfile=/home//.vnc/%h%i.pid

execstop=/bin/sh -c '

/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :

'[install]

wantedby=multi-user.target

修改後:

[unit]

description=remote desktop service (vnc)

after=syslog.target network.target

[service]

type=forking

# clean any existing files in /tmp/.x11-unix environment

execstartpre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

execstart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i -geometry 1376x730"

pidfile=/home/root/.vnc/%h%i.pid

execstop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[install]

wantedby=multi-user.target

4:(1)重新載入 systemd,掃瞄新的或有變動的單元:systemctl daemon-

reload

[root@xwq system]# systemctl daemon

-reload(2

)為登陸的root使用者新增乙個密碼

[root@xwq system]# vncpasswd root

password:輸入你的密碼

verify:再次輸入你的密碼(3

)啟動vnc桌面

[root@xwq system]# vncserver :

1you will require a password to access your desktops.

password:輸入你的密碼

verify:再次輸入你的密碼

xauth: file /root/.xauthority does not exist

xauth: (stdin):

1: bad display name "

xwq:1"in

"add

"command

new

'xwq:1 (root)

' desktop is xwq:1

creating

default startup script /root/.vnc/xstartup

in /root/.vnc/xstartup

log file

is /root/.vnc/xwq:1

.log

(4)用下面的命令(永久的)開啟服務

[root@xwq system]# systemctl enable vncserver@:

1.service

如果輸入systemctl enable vncserver@:

1.service命令輸出了如下**,

[root@xwq system]# systemctl enable vncserver@:1.service

ln -s '/usr/lib/systemd/system/vncserver@:1.service' '/etc/systemd/system/multi-user.target.wants/vncserver@:1.service'

請在終端輸入這行命令:echo "127.0.0.1 xwq"> /etc/hosts

(5)輸入以下命令配置防火牆規則:

[root@xwq ~]# firewall-cmd --permanent --zone=public --add-port=5901/tcp

success

[root@xwq ~]# firewall-cmd --reload

success

5:使用windows端安裝vnc viewer訪問redhat,可以成功訪問。

:其他命令

關閉vnc服務:systemctl stop vncserver@:

1.service

禁止 vnc 服務開機啟動:systemctl disable vncserver@:

1.service

關閉防火牆:systemctl stop firewalld.service

Redhat7安裝Madagascar簡易教程

madagascar 是當前地球物理界比較流行和熱門的一套開源軟體 已經遷移到git上,由於更新速度快 開源的特性,再加上fomel等人的大力推廣,發展勢頭很猛,有超越su的趨勢。1.二 依賴軟體包 的安裝在下面的 根據自己系統版本選擇下軟體依賴包。redhat7已經更新python為2.7,所以這...

Nginx Nginx在Redhat7上安裝教程

cd wget cd nginx 1.6.3 configure prefix home yveshe nginx make make install configure 檢查依賴 make make install 編譯安裝 如果安裝失敗的原因是由於缺少依賴,考慮安裝以下依賴來解決問題 yum i...

redhat7上準備docker環境

開啟筆記本發現上面還留有乙個redhat7的作業系統,正好拿來用用,結果發現密碼忘記了。重新再建個也挺麻煩的,只好看看如何重置密碼 順利進入redhat,配置個ip,還是習慣xshell5,輸個ip直接登入,弄了1個小時才把這些弄好,至少還是舒坦了 然後是要安裝docker 新增docker yum...