Theme: x-window graphic variables Plan


Download 53 Kb.
Sana16.06.2020
Hajmi53 Kb.
#119286
Bog'liq
OT musaqil ish


Theme: x-window graphic variables

Plan:

I. Introduction

II. main part

II.1. Articles Related

II.2. Syntax: The environment variable

II.3Management: How to set the DISPLAY variable

III. conclusion

IV. references

I. The magic word in the X window system is DISPLAY.

The DISPLAY environment variable instructs an X client which X server it is to connect to by default.

The X display server install itself normally as display number 0 on your local machine. In Putty, the “X display location” box reads localhost:0 by default.

A display consists (simplified) of:

a keyboard,

a mouse


and a screen.

A display is managed by a server program, known as an X server. The server serves displaying capabilities to other programs that connect to it.

The remote server knows where it have to redirect the X network traffic via the definition of the DISPLAY environment variable which generally points to an X Display server located on your local computer.

The SSH protocol has the ability to securely forward X Window System applications over an encrypted SSH connection, so that you can run an application on the SSH server machine and have it put its windows up on your local machine without sending any X network traffic in the clear. $DISPLAY on the remote machine should point to localhost. SSH does the forwarding.

X11 means that the display of a remotely running program is authorized to be sent to your machine (localhost) via an X11 connection between a client (located on the remote server) and a server (running on your machine).

When you want to redirect the display (keyboard, mouse, screen, …) of a remote server on the local computer, you use the X window system.

It can be generally the case in a Linux installation (Database, …) when you are not installing the software on your local computer.

The X Window System (commonly X or X11) is a computer software system and network protocol that provides a graphical user interface (GUI) for networked computers known also as X emulation.

Running X applications over the network is quite bandwidth-intensive. If you are off campus or running highly-graphical applications, it may take a few moments for the screen to refresh.

The X Server is also known as:

X Display server (from DISPLAY)

X-Windows server (if the X Server is a Windows application)

and is an important part of the X Windows System.

It's located on your machine (laptop, localhost).

All graphical UNIX/LINUX applications connect to an X-Windows Server to display graphical data on the monitor of the computer when you use the X Windows system.

The X-Windows Server is a program that acts as an interface between graphical UNIX/LINUX applications and the graphics subsystem of the computer.

Microsoft Windows does not come with support for X, but many third-party implementations (X-Windows server) exist such as:

Cygwin/X,

Xming

X-Win32,


Exceed

and WeirdX.



II.1. X11 - How to display remote clients (such as firefox, installation screen) with the X Server CygwinX ?

The X Windows System permit to see on your local computer, software that run on a remote server. This software are known als:

X Window System applications

remote client

This articles shows a step by step tutorial.

Start the server on your machine

Start a X server on your machine for instance X11 - Cygwin/X

To do that start XLaunch.

Program Files > Cygwin-X > Xlaunch

The SSH protocol has the ability to securely forward X Window System applications over your encrypted SSH connection, so that you can run an application on the SSH server machine and have it put its windows up on your local machine without sending any X network traffic in the clear.

To enable x forwarding, you have two ways:

with the openssh package of Cygwin

with putty

Breadcrumb:

X11 - How to display remote clients (such as firefox, installation screen) with the X Server CygwinX ?

Advertising

X Windows System (commonly X or X11) 11 pages

Configuration

Cygwin/X

How to display remote clients (such as firefox, installation screen) with the X Server CygwinX ?

DISPLAY (environment variable)

X11 and su: How to ?

X Client

X Server (X-Windows, X Display Server)

Xclock

Xhost


Xinetd

Xterm


X11 - How to display remote clients (such as firefox, installation screen) with the X Server CygwinX ?

> SSH (Secure Shell) - Remote Access > X Windows System (commonly X or X11)

The X Windows System permit to see on your local computer, software that run on a remote server. This software are known als:

X Window System applications

remote client

Steps


Start the server on your machine

Start a X server on your machine for instance X11 - Cygwin/X

To do that start XLaunch.

Program Files > Cygwin-X > Xlaunch

Make a connection with X11 forwarding

Enabled


The SSH protocol has the ability to securely forward X Window System applications over your encrypted SSH connection, so that you can run an application on the SSH server machine and have it put its windows up on your local machine without sending any X network traffic in the clear.

To enable x forwarding, you have two ways:

with the openssh package of Cygwin

with putty

With openssh

Make sure you have the openssh package installed.

Launch Cygwin/X

In an X terminal, you can run the following in an X terminal:

$ ssh -Y username@remote_hostname_or_ip_address

where the Y parameter enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls.

Enter your password when prompted by ssh.

Your ssh session should now show you a shell prompt for your remote machine.

With Putty

Launch Cygwin/X. Close the X terminal windows if necessary

Open Putty and change the X11 forwarding configuration as below:

The X display location box is blank by default, which means that PuTTY will try to use a sensible default such as :0, which is the usual display location where your X server will be installed.

Made a connection and enter your credentials

Launch remote X clients

From Putty of OpenSsh, you have now a ssh connection and you can now launch remote X clients in your session. For example:

$ firefox&

By appending & to the command name, the remote clients start in the background and you don't have to open several others ssh sessions.

Disabled


Without the X11 forwarding, you are subjected to the X11 SECURITY and then you must:

authorize the remote server to make a connection with the local X Server using a method (for instance, the xhost command)

set the display environment variable to redirect the output to the X server of your local computer.

In this example:

192.168.2.223 is the IP of the server

192.168.2.2 is the IP of the local computer where the x server is installed. localhost can also be used.

gerardnico@gerardnico01 ~

$ xhost 192.168.2.223

192.168.2.223 being added to access control list

gerardnico@gerardnico01 ~

$ ssh -l root 192.168.2.223

root@192.168.2.223s password:

Last login: Sat May 22 18:59:04 2010 from rixni01.cornac.net

[root@oel5u5 ~]# export DISPLAY=192.168.2.2:0.0

[root@oel5u5 ~]# echo $DISPLAY

192.168.2.2:0.0

[root@oel5u5 ~]# xclock&

Then the xclock application must launch.

By starting the remote clients in the background, by appending & to the command name (xclock&), you don't have to open several ssh sessions.

The X Server is also known as:

X Display server (from DISPLAY)

X-Windows server (if the X Server is a Windows application)

and is an important part of the X Windows System.

It's located on your machine (laptop, localhost).

All graphical UNIX/LINUX applications connect to an X-Windows Server to display graphical data on the monitor of the computer when you use the X Windows system.

The X-Windows Server is a program that acts as an interface between graphical UNIX/LINUX applications and the graphics subsystem of the computer.

Microsoft Windows does not come with support for X, but many third-party implementations (X-Windows server) exist such as:

Cygwin/X,

Xming

X-Win32,


Exceed

and WeirdX.

After making a connection, you shows X windows by following for instance this article: X11 - How to display remote clients (such as firefox, installation screen) with the X Server CygwinX ?.

But when you change of user with the su command, you got .

su - oracle

Error: Can't open display:

There is no display You then go back to the original session, get the display, log as the other and set the display

>exit


logout

>echo $DISPLAY

localhost:10.0

>su - oracle

/home/oracle >export DISPLAY=localhost:10.0

But when trying to start a X windows, we get an authorization problem

/home/oracle >xlogo

Xlib: connection to "localhost:10.0" refused by server

Xlib: PuTTY X11 proxy: Authorisation not recognised

Error: Can't open display: localhost:10.0

The Solution

You need for each new su session to set:

the DISPLAY

and the authorization cookie.

Example

From the original user, get the display



echo $DISPLAY

localhost:10.0

From the original user, get the magic cookie. This is the last on on the list

xauth list

euramsodw011.hotitem.local/unix:12 MIT-MAGIC-COOKIE-1 7bb18f920440391643b12a1467764e8e

euramsodw011.hotitem.local/unix:13 MIT-MAGIC-COOKIE-1 d6ac161e55a0a7c320908cd35d1b8391

euramsodw011.hotitem.local/unix:11 MIT-MAGIC-COOKIE-1 bae3fc9da4d089b69aa98a84238fc7bc

euramsodw011.hotitem.local/unix:10 MIT-MAGIC-COOKIE-1 937b307935d2485e773970b48bb21eaf

From my colleague, Pepijn Dekker, in order to get the cookie statement (with grep and awk)

xauth list | grep unix:`echo $DISPLAY | awk -F: '{print $2}' | awk -F. '{print $1}'` | awk '{print "xauth add " $0}'

xauth add euramsodw011.hotitem.local/unix:10 MIT-MAGIC-COOKIE-1 937b307935d2485e773970b48bb21eaf

su the user that you want to impersonate, set the display and add the cookie, start an x windows

su - oracle

export DISPLAY=localhost:10.0

xauth add euramsodw011.hotitem.local/unix:10 MIT-MAGIC-COOKIE-1 937b307935d2485e773970b48bb21eaf

xclock


And you see the xclock as the impersonate user.

II.2. Syntax: The environment variable

A variable is a parameters referenced by a name.

A variable (ie a name used to store data) in bash is called a parameter. A variable in bash is one of the three type of parameters.

A variable has:

a value

and zero or more attributes (such as integer, …). Attributes are assigned using the declare builtin command.



e - The Data Blog

Breadcrumb:

X11 - DISPLAY (environment variable)

Advertising

X Windows System (commonly X or X11) 11 pages

Configuration

Cygwin/X

How to display remote clients (such as firefox, installation screen) with the X Server CygwinX ?

DISPLAY (environment variable)

X11 and su: How to ?

X Client

X Server (X-Windows, X Display Server)

Xclock

Xhost


Xinetd

Xterm


II.3. Management: How to set the DISPLAY variable.

With Putty

Generally you are using the putty terminal to connect.

Launch Cygwin/X. Close the X terminal windows if necessary

Open Putty and change the X11 forwarding configuration as below:

The X display location box is blank by default, which means that PuTTY will try to use a sensible default such as :0, which is the usual display location where your X server will be installed.

Made a connection and enter your credentials.

Launch remote X clients

From Putty of OpenSsh, you have now a ssh connection and you can now launch remote X clients in your session. For example:

$ firefox&

$ xlogo

$ xclock


will launch an x terminal running on your remote host that will display on your Cygwin/X screen.

By appending & to the command name, the remote clients start in the background and you don't have to open several others ssh sessions.

Breadcrumb:

X11 - How to display remote clients (such as firefox, installation screen) with the X Server CygwinX ?

Advertising

X Windows System (commonly X or X11) 11 pages

Configuration

Cygwin/X


How to display remote clients (such as firefox, installation screen) with the X Server CygwinX ?

DISPLAY (environment variable)

X11 and su: How to ?

X Client


X Server (X-Windows, X Display Server)

Xclock


Xhost

Xinetd


Xterm

The X Windows System permit to see on your local computer, software that run on a remote server. This software are known als:

X Window System applications

remote client

This articles shows a step by step tutorial.

II. Articles Related

X Windows System (commonly X or X11)

OBIEE - Catalog Manager

X11 - Xterm

X11 - Cygwin/X

X11 - DISPLAY (environment variable)

Linux - Enable Remote Desktop on Oracle Enterprise Linux / Red Hat with Gnome

OBIEE 11g - Oracle Business Intelligence 11.1 Simple installation steps on Windows and OEL Linux 32 bit

OBIEE - 12.2.1.3 - Linux Installation 12C on Azure

Oracle Database 11gR2 - Installation on Linux OEL 5 Update 5 (x86_64)

X11 - X11 and su: How to ?

Steps:


Start the server on your machine

Start a X server on your machine for instance X11 - Cygwin/X

To do that start XLaunch.

Program Files > Cygwin-X > Xlaunch

Make a connection with X11 forwarding

Enabled


The SSH protocol has the ability to securely forward X Window System applications over your encrypted SSH connection, so that you can run an application on the SSH server machine and have it put its windows up on your local machine without sending any X network traffic in the clear.

To enable x forwarding, you have two ways:

with the openssh package of Cygwin

with putty

With openssh

Make sure you have the openssh package installed.

Launch Cygwin/X

In an X terminal, you can run the following in an X terminal:

$ ssh -Y username@remote_hostname_or_ip_address

where the Y parameter enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls.

Enter your password when prompted by ssh.

Your ssh session should now show you a shell prompt for your remote machine.

Advertising

With Putty

Launch Cygwin/X. Close the X terminal windows if necessary

Open Putty and change the X11 forwarding configuration as below:

The X display location box is blank by default, which means that PuTTY will try to use a sensible default such as :0, which is the usual display location where your X server will be installed.

Made a connection and enter your credentials

Launch remote X clients

From Putty of OpenSsh, you have now a ssh connection and you can now launch remote X clients in your session. For example:

$ firefox&

$ xlogo


$ xclock

will launch an x terminal running on your remote host that will display on your Cygwin/X screen.

By appending & to the command name, the remote clients start in the background and you don't have to open several others ssh sessions.

Disabled


Without the X11 forwarding, you are subjected to the X11 SECURITY and then you must:

authorize the remote server to make a connection with the local X Server using a method (for instance, the xhost command)

set the display environment variable to redirect the output to the X server of your local computer.

In this example:

192.168.2.223 is the IP of the server

192.168.2.2 is the IP of the local computer where the x server is installed. localhost can also be used.

gerardnico@gerardnico01 ~

$ xhost 192.168.2.223

192.168.2.223 being added to access control list

gerardnico@gerardnico01 ~

$ ssh -l root 192.168.2.223

root@192.168.2.223s password:

Last login: Sat May 22 18:59:04 2010 from rixni01.cornac.net

[root@oel5u5 ~]# export DISPLAY=192.168.2.2:0.0

[root@oel5u5 ~]# echo $DISPLAY

192.168.2.2:0.0

[root@oel5u5 ~]# xclock&

Then the xclock application must launch.

In the console

Setting the DISPLAY variable, depend of your shell

Bourne, Bash or Korn shell:

$ export DISPLAY=localhost:0.0

C shell

% setenv DISPLAY localhost:0.0



In this example, local_host is the host name or IP address of the local computer that you want to use to display for instance an installation screen such as Oracle Universal Installer.

For a sudo session

In a sudo session (you log on to a host as a non-root user and then create a sudo session to perform administrative functions)

If you do this remotely, multiple credentials may be used. If you simply try sudo xterm, it won’t work, because the xterm is running as root, but root doesn’t have the proper X11 authentication to connect to the X server machine.

To run an X11-based tool, you need to set the proper X credentials in the sudo session by fixing the xauth profile for root.

So copy the following in your root .bash_profile, substituting your logon username for adminuser:

su - adminuser -c 'xauth list' |\

grep `echo $DISPLAY |\

cut -d ':' -f 2 |\

cut -d '.' -f 1 |\

sed -e s/^/:/` |\

xargs -n 3 xauth add

In God we trust , all others must bring data.

W.E. Deming



III.This is meant to be a simple overview of X11 programming. It will contain the basics necessary to create a single window X program. All of the information of this will pertain simply to programming with the X11 libraries which come standard with X11R[5/6]. It goes without saying, but this page is under constuction at all times.

Overview of X11 Programming

X is a fun-filled graphical system for most flavors of UNIX. There are many toolkits for programming X, but learning to use the X Library calls is a tried and true method which yields highly portable code. This document is meant to be a short introduction to some of the things I have learned about it myself. It will probably always remain "under construction". Strap yourself in and hold on! This train's bound for glory, this train's coming through and one of these days these trains are going to walk all over you!

Header Files for X

Here are the header files required to do much of anything in X. The order is important:

#include

#include

#include

These files can typically be found in /usr/include/X11. I highly recommend looking though the header files themselves, but don't get caught up on trying to figure out everything at once! The best way to learn them is to continually consult them as you continue to work with X.

Important X Variables

X has a number of important variables for handling windows:

Display *dis;

int screen;

Window win;

GC gc;

The display points to the X Server. The screen refers to which screen of the display to use. Setting up the connection from the X Client to the X Server typically involves a line like: setenv DISPLAY my.machine.where.ever:0. The my.machine.where.ever is tied in with the Display* and the screen is connected with the :0 part of the variable. The Window controls the actual window itself (duh! ;^). And the GC is the graphics context.



The graphics context has a lot to do with how things are displayed/drawn in the window. Different masks can be set, etc. and you can get pretty funky with it.

Typically calls to get input and output to the window use one or more of the above variables. See the appropriate sections for details.

Overview of X11 Programming

X is a fun-filled graphical system for most flavors of UNIX. There are many toolkits for programming X, but learning to use the X Library calls is a tried and true method which yields highly portable code. This document is meant to be a short introduction to some of the things I have learned about it myself. It will probably always remain "under construction". Strap yourself in and hold on! This train's bound for glory, this train's coming through and one of these days these trains are going to walk all over you!

Header Files for X

Here are the header files required to do much of anything in X. The order is important:

#include

#include

#include

These files can typically be found in /usr/include/X11. I highly recommend looking though the header files themselves, but don't get caught up on trying to figure out everything at once! The best way to learn them is to continually consult them as you continue to work with X.

Important X Variables

X has a number of important variables for handling windows:

Display *dis;

int screen;

Window win;

GC gc;


The display points to the X Server. The screen refers to which screen of the display to use. Setting up the connection from the X Client to the X Server typically involves a line like: setenv DISPLAY my.machine.where.ever:0. The my.machine.where.ever is tied in with the Display* and the screen is connected with the :0 part of the variable. The Window controls the actual window itself (duh! ;^). And the GC is the graphics context.

The graphics context has a lot to do with how things are displayed/drawn in the window. Different masks can be set, etc. and you can get pretty funky with it.

Typically calls to get input and output to the window use one or more of the above variables. See the appropriate sections for details.

IV.

Sites: https://gerardnico.com



https://mech.math.msu.su
Download 53 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling