I just learned how to run a remote Linux program in a graphical way in windows. I am interested and don't want to go to bed. I want to know how to run a remote Linux program in Linux, and it must be graphical. After a long search, I finally found it and successfully tested it in redhat9.
Server: 10.187.82.168
Client: 10.187.82.130 B
That is to say, run the program on B (graphical and text can certainly be better)
Steps:
Perform the following operations on machine B:
1. #: xhost + 10.197.82.168
2. #: SSH 10.187.82.168
3. Enter the root password (for server)
3. #: Display = 10.187.82.130: 0
4 #: gedit
The exciting gedit interface appeared. Now all the operations are running on machine A. Are you very excited? This is a powerful Linux. I found that I like it more and more.
Expand knowledge:
The role of the display environment variable
In Linux/UNIX operating systems, display is used to set where the image is displayed. directly log on to the graphic interface or log on to the command line interface and use startx to start the graphics. The display environment variable is automatically set to 0: 0. At this time, you can open the terminal and output the name of the graphics program (such as xclock) to start the program. The image is displayed in the local window. Enter printenv on the terminal to view the current environment variable. The output result contains the following content:
You can use xdpyinfo to view more detailed information currently displayed.
The display environment variable format is host: NUMA. numb, host refers to the host name or IP address of the xserver. The image is displayed on this host. It can be a Linux/Unix machine that has started the graphic interface, or exceed installed, x-deep/32 and other Windows Operating xserver Windows machines. if the host is empty, the xserver runs on the local machine, and the graphics program (xclient) connects to the xserver using UNIX socket instead of TCP. when a TCP connection is used, numa is the connected port minus the value of 6000. If NUMA is 0, it indicates that it is connected to Port 6000; when the UNIX socket method is used for connection, it indicates the path of the connected UNIX socket. If it is 0, it indicates connecting to/tmp /. x11-unix/x0. numb is almost always 0.
If you use su username or Su-username to switch to another user, and use the command
When you set the display environment variable and run a graphic program (such as xclock), you will receive the following error:
Xlib: connection to ": 0.0" refused by Server Xlib: no protocol specifiedError: can t open display: 0.0 |
This is because xserver does not allow other users' graphics to be displayed on the current screen by default. if you want other users' images to be displayed on the current screen, run the following command as the current login user, that is, the user before switching the identity:
This command will allow other graphical programs started by other users to display the graphics on the current screen.