Linux getting started Tutorial: What is X Window?

Source: Internet
Author: User

Linux getting started Tutorial: What is X Window?

The well-known X Window is certainly a stranger to everyone. We all know that it is a Windows system under Unix/Linux, and it is based on the Server/Clinet architecture. You can also find a lot of Introduction to X Windows on the Internet. There are many articles to give users an intuitive impression, often let the system enter the plain text interface, and then use startx to start the graphic interface, or directly use X to start X Server, then run an xterm for demonstration. I think the above articles have limited understanding of X Window, and they are not deep enough. So here I write an article "What is X Window", take the latest Ubuntu-14.04 Desktop as an example, show how to learn X Window.

Let's talk a little bit. After posting the previous article "create your own Vim", someone in the comments will share the configuration file. At that time, I said: the configuration file is not long. I just need to tap the code according to the picture. As a result, I did the "Image-based coding" thing myself today, but it didn't take much time, just a few minutes. The reason is that when I tried X Window today, I dropped the system and reinstalled the system. Then I had to set Vim again.

Understand X Windows on your machine

X Window is actually a specification, which has many different implementations. in Linux, Xorg and XFree86 are most popular. in Microsoft Windows, X Window is also implemented, apple's Mac is also a type of X Window. To know which X Window is running on your machine, you can use the ps command to view the process, such:

We can see that the X Window used by Ubuntu 14.04 is Xorg. If you use the ps-ef command, you can also see the command line parameters when Xorg is running.

To learn about X Window, read the following documents first:

The following is a well-known basic knowledge: X Window is a layered architecture, which can be divided into Serve and Client. X Server is responsible for graphical display and user input. The Client program needs to connect to X Server and then request X Server to draw a graphical interface. At the same time, X Server receives user input. In a desktop system, X Server and Client programs are often installed on the same machine, and generally do not feel hierarchical during daily use. However, it is clear that X Server and Client can run programs on different machines respectively, while the graphic interface is displayed on another machine.

The concept of Server and Client in X Window is the opposite to the concept of "Server/Client" that we usually use. Many people familiar with Internet principles will be confused when they first come into contact with the concepts of X Window. For example, I run Ubuntu 14.04 desktop on a local machine and CentOS 5.10 (pure character Interface) on another remote machine ), when I use ssh to connect to CentOS from Ubuntu, Ubuntu is a Client and CentOS is a Server. In X Window, Server is the Ubuntu in front of me, and X Server runs on Ubuntu. I can run GVim in CentOS, but the window is displayed in Ubuntu. GVim is a Client program that runs on a remote machine, and its window is displayed locally.

Understand the display and virtual console

As mentioned above, many articles about X Window on the Internet first let the system enter the character interface, and then manually start an X Server. In fact, this is completely unnecessary, because on the same machine, you can run multiple X servers, just make the display of each X Server different. So what is display?

In X Window, you can use hostname: display_number.screen_number to specify a screen. It can be understood that a computer can have multiple displays and one display can have multiple screens. Therefore, display is equivalent to a set of input and output devices provided by a computer. Generally, a computer is equipped with only one keyboard, mouse, and one monitor. In special cases, multiple monitors can be configured.

Now the problem arises. My computer only has one set of keyboard and mouse and one display, that is, only one display. How can I run multiple X servers? That's because there are advanced features such as the virtual console in Linux. You can switch between different virtual consoles by pressing Ctrl + Alt + F1, Ctrl + Alt + F2,..., Ctrl + Alt + F7 at the same time. In Ubuntu 14.04, the virtual console 1 to 6 runs the getty interface, that is, the character interface. The virtual console 7 runs Xorg. (In Fedora, virtual console 1 runs a graphical interface, while others use a character interface .)

We can directly run the X Server program to start X Server. /Usr/bin/X and Xorg are both X Server programs. In fact,/usr/bin/X is the symbolic link of Xorg, which is the same.

You can specify the display parameter when starting X Server. Because hostname and screen_number can be omitted, you can specify the display in the format of: 0,: 1. On my machine, there was an X Server running, and display: 0 was occupied, so I used sudo X: 1-retro to display: 1 and then run an X Server, for example:

The-retro parameter is used to display the background of X Server as twill. Otherwise, the background is pure black, so it cannot be seen whether X Server is enabled. The following figure shows the effect after X Server is started:

Press Ctrl + Alt + F7 to return to display: 0. Then run the ps command to check whether there are two Xorg running systems, one running on the virtual console 7 and the other running on the virtual console 8. For example:

Run GVim in the newly started X Server to check the effect. When running GVim, use the-display: 1 parameter to specify the window to be displayed on the newly started X Server, and use the-geometry parameter to specify the window size and position. Then press Ctrl + Alt + F8 to switch to the virtual console. For the command, see:

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • 3
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.