DISPLAY環境變量格式如下host:NumA.NumB,host指Xserver所在的主機主機名或者ip地址,圖形將顯示在這一機器上,可以是啟動了圖形界面的Linux/Unix機器,也可以是安裝了Exceed 、X-Deep/32等Windows平台運行的Xserver的Windows機器。
如果Host為空白,則表示Xserver運行於本機,並且圖形程序(Xclient)使用unix socket方式連接到Xserver,而不是TCP方式。使用unix socket方式連接時則表示連接的unix socket的路徑,如果為0,則表示連接到/tmp/.X11-unix/X0
如果Host非為空白, 使用TCP方式連接時,NumA為連接的端口減去6000的值,如果NumA為0,則表示連接到6000端口;
NumA + 6000 = tcp port #
NumB則幾乎總是0。
---------------------------- 進階 ------------------------------------------------------------------------
如果使用su username或者su - username切換到別的用戶,並且使用命令
export DISPLAY=:0.0
設置DISPLAY環境變量,運行圖形程序(如xclock)時會收到如下錯誤:
Xlib: connection to ":0.0"refused by server
Xlib: No protocol specified
Error: Can't open display: :0.0
這是因為Xserver默認情況下不允許別的用戶的圖形程序的圖形顯示在當前屏幕上.如果需要別的用戶的圖形顯示在當前屏幕上,則應以當前登陸的用戶,也就是切換身份前的用戶執行如下命令
xhost +
這個命令將允許別的用戶啟動的圖形程序將圖形顯示在當前屏幕上.
在2台Linux機器之間,如果設置服務器端配置文件/etc/ssh/sshd_config中包含:
X11Forwarding no
客戶端配置文件/etc/ssh/ssh_config包含:
ForwardX11 yes
則從客戶端ssh到服務器端后會自動設置DISPLAY環境變量,允許在服務器端執行的圖形程序將圖形顯示在客戶端上.在服務器上查看環境變量顯示如下(這個結果不同的時候並不相同)
DISPLAY=localhost:10.0
在客戶機上用netstat -lnp可以看到有程序監聽了6010端口
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 4827/1
如果希望允許遠程機器上的圖形程序將圖形顯示在本地機器的Xserver上,除了要設置遠端機器的DISPLAY環境變量以外,還需要設置本地機器的Xserver監聽相應的TCP端口.而現在的Linux系統出於安全的考慮,默認情況下不再監聽TCP端口.可通過修改/etc/X11/xinit/xserverrc文件,將
exec /usr/bin/X11/X -dpi 100 -nolistentcp
修改為
exec /usr/bin/ X11/X -dpi 100
允許在直接使用startx啟動圖形時啟動對TCP端口的監聽.
修改/etc/kde3/kdm/kdmrc,將
ServerArgsLocal=-nolisten tcp
修改為
ServerArgsLocal=
允許kdm作為顯示管理器時,啟動會話時監聽相應的TCP端口.
修改/etc/gdm/gdm.conf,在[Security]一節增加
DisallowTCP=false
或者在登陸窗口選擇"Options" -> "Configure Login Manager..."的Security頁面,取消"DenyTCP connections to Xserver",允許gdm作為顯示管理器時,啟動會話時監聽相應的TCP端口.
--------------------------------------------------------------------------------------------------------
xhost
xhost是用來控制X server訪問權限的。
通常當你從hostA登陸到hostB上運行hostB上的應用程序時,
做為應用程序來說,hostA是client,但是作為圖形來說,
是在hostA上顯示的,需要使用hostA的Xserver,所以hostA是
server.因此在登陸到hostB前,需要在hostA上運行xhost +
來使其它用戶能夠訪問hostA的Xserver.
xhost +是使所有用戶都能訪問Xserver.
xhost + ip使ip上的用戶能夠訪問Xserver.
xhost + nis:user@domain使domain上的nis用戶user能夠訪問
xhost + inet:user@domain使domain上的inet用戶能夠訪
youtube 教學 : Open GUI apps on Windows Subsystem for Linux (and on Raspberry Pi)
2019-11-28
2019-11-27
Debian Buster --- net-tools will be deprecated in favor of iproute2
Here is a summary of the net-tools commands, together with their iproute2 equivalent:
legacy net-tools commands | iproute2 replacement commands |
---|---|
arp | ip n (ip neighbor) |
ifconfig | ip a (ip addr), ip link, ip -s (ip -stats) |
iptunnel | ip tunnel |
nameif | ip link |
netstat | ss, ip route (for netstat -r), ip -s link (for netstat -i), ip maddr (for netstat -g) |
route | ip r (ip route) |
from debian stretch (9 release note)
2019-11-20
LENOVO T410 with Debian Buster and XFCE
1. modify /etc/apt/sources.list : add contrib and non-free
2. install intel wifi driver : firmware-iwlwifi
3. Install nvidia driver : install/run nvidia-detect, install nvidia-legacy-340xx-driver
4. Whenever I lock my screen, it goes full black and does not respond either to moving the cursor or pressing keys from the keyboard.
2. install intel wifi driver : firmware-iwlwifi
3. Install nvidia driver : install/run nvidia-detect, install nvidia-legacy-340xx-driver
4. Whenever I lock my screen, it goes full black and does not respond either to moving the cursor or pressing keys from the keyboard.
After searching for a while, I found the solution in the Arch Wiki.
The solution is pretty simple. Just create a text file named 20-intel.conf in the /etc/X11/xorg.conf.d/ directory path (you may have to create directory xorg.conf.d if it does not exist) and paste the following in it:
Section "Device"
Identifier "Nvidia Card"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "NVS 3100M"
EndSection
Now save the file and reboot your Debian Xfce system.
Screen black problem after locking the screen in Xfce should be solved by now.
5. How to enable my keyboard's volume keys in XFCE?
- Right click a panel -> Panel submenu -> Add New Items...
- Add an instance of PulseAudio Plugin
- Right click the icon that just appeared in your panel and click "Properties". Make sure "Enable keyboard shortcuts for volume control" is enabled.
You may have to install the PulseAudio Plugin first. In Debian and Debian-based distributions, the package is called xfce4-pulseaudio-plugin.