5.3 Working with X-windows

5.3.1 How to switch between text and graphical consoles?

Pressing the key combination <Ctrl><Alt><F1> will switch you to to the first text console at any time. <Ctrl><Alt><F2> will switch you to the second text console, <Ctrl><Alt><F3> to the third text console, etc, up to <Ctrl><Alt><F6>, for the total of 6 text consoles. <Ctrl><Alt><F7> will switch you to the first graphical user interface (GUI) console if one is running. <Ctrl><Alt><F8> to the second GUI console, etc., up to <Ctrl><Alt><F11> for the total of 5 GUI consoles. The 12th console is either used as the 6th GUI (RedHat 6.1) or a place to which kernel messages are continually displayed (Mandrake 7.0, really cool feature). Typically none or only the first GUI console is running.

<Ctrl><Alt><F1> means: "Press the left <Ctrl> and <Alt> keys and hold them. Now press <F1>. Release <F1>. Release <Ctrl> and <Alt> keys."

Thus, sitting at a Linux computer I can have many consoles opened at the same time, and I can switch between them using the hot keys as described above. I have to log in on each console to be able to use it--I may log in as the same user (multiple times), or different users. Each login session is quite separate; they should not interfere with each other (the X sessions sometimes may if you log in as the same user twice). The first 6 consoles are text-based, command-line terminals (CLI, "command line interface") and are named tty1, tty2 ... tty6 (historical name, "tty" stands for "teletypewriter"). The subsequent consoles are graphical (GUI). These are all *local* consoles--my local Linux computer is truly multiuser and multitasking.

You can connect to a Linux computer remotely, over a network. While connected, you can have a program run on the remote Linux server and the display sent to your terminal on your "local" console. This local console can be Linux-based or another operating system-based. One cannot run programs remotely on an MS Windows server, but it is often used with Linux. It is really helpful to be able to distinguish if your program is run locally or remotely.

The full-screen text consoles are terminals by themselves. Under the GUI consoles, you can also create "slave" pseudo-terminals (in a window) on demand--they will be called pts0, pts1, ....

Sitting at a text terminal, you can determine the name of your terminal using the following command:


I can determine the computer on which my current session is located using:

uname -a

The name of the command "uname" is derived from "UNIX name". It shows the operating system name, the server name, the version of the operating system kernel, and the time of the compilation of the kernel.

You can close any text terminal by typing "exit" inside it.

The Linux GUI console is quite similar to other GUIs you might have used, e.g., MS Windows, but there are also numerous important differences. I love multiple "desktops" to stay organized--the default setup in KDE offers 4 desktops (it can be customized to between 1 and 16). I run many programs and never close them, so to stay organized I keep a connectivity application (netscape with all its windows, knode newsreader, and licq) together on Desktop2, abiword, staroffice and a text editor on Desktop3, games and konqueror with helpfiles on Desktop4, and leave Desktop1 for the more occasional chores. One can switch between desktops by clicking on the "desktop pager" on the "K-panel" or using <Ctrl><TAB>. To switch between applications on a same desktop, I may click the application window, or click its icon representation on the "applicaton panel", or use <Alt><TAB> to toggle between the applications. <Ctrl><Esc> will give me a list of the processes currently run on the local machine ("localhost").

5.3.2 How do I setup video card, monitor and mouse for the X-server?

This should be set-up during your Linux initial installation unless you skipped the step. To set it up now, you may try, as root, one of these text-mode configurators (as root):




Under RedHat, you can also run the command setup (as root) and access Xconfigurator from there.

To setup X-windows under Linux, you may need to know your hardware. You may want to dust your monitor manual to see what maximum synchronization frequencies (vertical and horizontal) your monitor supports. The message when the computer boots may give you a clue about what type of video card you have and with how much video memory. Also running these commands will likely provide helpful information:



Read the label underneath your mouse to find out about the mouse type. Next time you buy a mouse, get a 3-button "Linux-ready" Logitech or similar (Linux makes good use of all three mouse buttons). A standard (clone or not) mouse always makes a good sense--I would never buy an unusual mouse because it may requires a weird driver or otherwise be a installation/functional pain.

During testing of the X-server, if the screen goes blank, displays funny lines, or otherwise obviously does not function as designed, kill it fast with <Ctrl><Alt><BkSpace> and re-check your monitor sync frequencies. Running too high frequencies can be harmful to your monitor.

If you really have problems, set up a plain vga X server first (resolution 640x480 pixels, 16 or 256 colours). You can fine-tune it later, after you get some understanding of how things work on your system, or perhaps with the help of some nicer setup tools available under X.

After setting up X, you can start it manually using:

startx &

The "&" makes your command run in the background so that your text terminal is not blocked. You could also use:

init 5

which will switch your system to runlevel 5, which means "the graphical user interface run level". To start X automatically (or not, your choice) on the system reboot, read the next few paragraphs.

5.3.3 Can I have a GUI login prompt?

To start your X-server automatically on the system start-up and display a graphical login prompt, you have to change (as root) just one character in the file /etc/inittab. This file specifies something like:


Change it to


This sets up the default runlevel to 5, which is X-Windows. The meaning of the different runlevels is explained in the same /etc/inittab file :

0 - halt (Do NOT set initdefault to this)

1 - Single user mode

2 - Multiuser, without NFS (The same as 3, if you do not have networking)

3 - Full multiuser mode

4 - unused

5 - X11

6 - reboot (Do NOT set initdefault to this)

You can change the runlevel from the command line. E.g., this command (has to be executed as root):

init 6

will reboot your computer, while the following command would switch your computer to a single-user mode:

init 1

To find out which runlevel I am currently at, I use the command runlevel.

To fine-tune the appearance of my X login screen, I can use (under X):

kcontrol &

and select "System"-"Login Manager". I like a login screen with an analog clock, big font, the login name of the last user already typed in, and the focus pre-set on the password field in the dialog box.

5.3.4 How can I change my default desktop to KDE (or Gnome or yet another)

In my home directory, I create (or edit if it exists) the file .xsession using my favourite pico editor:

pico .xsession

[Pls note the dot at the beginning of the filename, files with names starting with dots are normally "invisible".]

On my RedHat 6.2 system, the file contains just one line:

exec startkde

KDE clearly works best for me, although it feels heavy on older hardware or under a load. Here is my list of windows managers available on the RedHat or Mandrake installation CD:

startkde (to run kde. on some systems, the command may be kde)

gnome-session (to run Gnome)

xfce (to run XFce, my favourite "lightweight" desktop)

afterstep (to run afterstep)

AnotherLevel (to run AnotherLevel)

fvwm2 (to run fvwm2)

fvwm (to run fvwm)

Of course, the alternative windows manager will run only if it is installed on your system. The above windows managers are available on RH/Mandrake CDs for you to decide if you want to install them. I use almost exclusively KDE, although the other managers may be smaller and faster. Gnome is a famous X-windows project which is said to be more advanced and is prettier than KDE, but it is still quite buggy, so perhaps not recommended unless you don't mind occasional trouble. RH6.x contains both major X-windows systems, Gnome and KDE.

5.3.5 Can I have multiple sessions of X running at the same time?

Yes, you can. When you issue the first startx command on your system, it opens the first X-session on the default display 0. The second X-session must be opened on a different display. For example, this will open a second X-session on the display 1:

startx -- :1

You can have up to 6 concurrent X sessions. Use <Ctrl><Alt><F7> to switch to display 0, <Ctrl><Alt><F8> to second screen, etc. up to <Ctrl><Alt><F12> Try man startx if you need more info.

In a similar fashion, you can open another bare X-server session without a window manager. This will open one on display 2:

xinit -- :2

On this bare-bone X-display I can run a different windows manager (so as to have two different ones running at the same time) by typing in the X-terminal window one of these (see the previous answer for more details):








5.3.6 Can my sister have second GUI login prompt so she does not have to kill my X-session to start hers?

To enable several concurrent GUI logins on different local consoles under RedHat (RedHat uses program gdm for graphical logins), I had to edit the file: /etc/X11/gdm/gdm.conf . I have the following entry at the end of this file to enable 4 login terminals <Ctrl><Alt><F7> to <Ctrl><Alt><F10>:


3=/usr/bin/X11/X vt10

2=/usr/bin/X11/X vt9

1=/usr/bin/X11/X vt8

0=/usr/bin/X11/X vt7

Having four GUI lets me run KDE and GNOME at the same time on one computer with two GUI terminals spare, so my sister can login despite my having screensavers with password-protection.

To enable several concurrent GUI logins on different local consoles under Mandrake (Mandrake uses kdm for graphical logins), I had to modify two files: /etc/X11/xdm/Xservers to include something like:

:0 local /usr/X11R6/bin/X :0

:1 local /usr/X11R6/bin/X :1

:2 local /usr/X11R6/bin/X :2

and /etc/X11/xdm/xdm-config to copy all the settings for display 0 to display 1 and 2 so that it includes this:

DisplayManager._0.authorize: true

DisplayManager._1.authorize: true

DisplayManager._2.authorize: true

DisplayManager._0.setup: /etc/X11/xdm/Xsetup_0

DisplayManager._0.startup: /etc/X11/xdm/GiveConsole

DisplayManager._0.reset: /etc/X11/xdm/TakeConsole

DisplayManager._1.setup: /etc/X11/xdm/Xsetup_0

DisplayManager._1.startup: /etc/X11/xdm/GiveConsole

DisplayManager._1.reset: /etc/X11/xdm/TakeConsole

DisplayManager._2.setup: /etc/X11/xdm/Xsetup_0

DisplayManager._2.startup: /etc/X11/xdm/GiveConsole

DisplayManager._2.reset: /etc/X11/xdm/TakeConsole

This enables me to run gnome and kde at the same time on a single computer with the third GUI terminal spare.

5.3.7 How to X-window remotely?


xhost name_of_the_remote_server

In the really secure environment of my house, I could even give all servers the permission to display on my screen using (don't do it when connnected to the Internet):

xhost +

startkde -display local_machine_name:0.0 &

The symbol "&" puts the command in the background, so that your telnet window is still available to you.

The 0.0 means "display zero, screen 0", which is your first screen on the first display and makes sense since you can have many concurrent sessions of X running on your computer with Linux.

You don't have to specify the "-display" option if your environment variable DISPLAY specifies the correct location on your current terminal, which is the case on my systems by default, but not on everybody else's as I am told. You can check your DISPLAY setting using:


xhost -name_of_the_remote_server


xhost -

Example. This sequence of commands will run Netscape on the remote machine called marie, directing the display to the X-server with X-windows manager which runs on the local machine hacker:


xhost marie

telnet marie


netscape -display hacker:0.0 &

[do my stuff]


xhost -marie

In principle, you can run a program on any computer on the network, and display the output on any other (not necessarily the one you are sitting at).

I use remote X-windowing a lot to run fat programs (kde, Word Perfect 8, and Netscape) on a slim machine (486-33, 8 MB mem) which would not be able to run those by itself. It is also a convenient and fast way to work with files on a remote system for which the nfs mount is not set up.

X-windows was designed to run remotely over the network. Remote X-windowing is a very powerful tool, on top of being quite a pleasant experience. Try it out.

You can even run a program on a remote Linux (or any Unix) computer and redirect the display to a local MS Windows machine if you install an X-windowing program for MS Windows. For a good overview of choices, see: http://www.linuxworld.com/linuxworld/lw-2000-09/lw-09-legacy_1.html

5.3.8 How do I install TrueType fonts from my MS Windows partition?

Some distributions come with a TrueType font server but no (or a limited choice of) TrueType fonts. You can install your own TrueType fonts though. Here is how I did it manually. Mandrake includes a GUI utility to transfer you MS Windows fonts to Linux, so you don't have to bother with the procedure below.

    1. From under K-menu (KDE), select "System"-"Font Manager" (or equivalent) and note what fonts you have installed.

    2. On the command line, check if the "free type" font server is installed:

rpm -q freetype

This queries (option "q") the rpm package manager for the package "freetype". If the package is installed, go to next step. If "freetype" is not installed, install it now from your distribution CD. "freetype" was installed on my system after a "full" RH installation.

    1. As root, make a directory that is to hold your TrueType fonts:

cd /usr/X11R6/lib/X11/fonts

mkdir TrueType

This directory is referred to in the configuration file /etc/X11/XF86Config so make sure that the name of the directory is exactly as shown. If you would like to name the directory differently, you have to edit /etc/X11/XF86Config and make appropriate adjustments. My "default installation" RedHat contained such a line:

FontPath "/usr/X11R6/lib/X11/fonts/TrueType"

    1. As root, copy your *.ttf files from the original location to the TrueType font directory that you just created. I took some TrueType from my MS Windows partition, you may need to use a different source location:

cd /usr/X11R6/lib/X11/fonts/TrueType

cp /mnt/dos_hda1/windows/fonts/my_private_fonts/*.ttf .

Before copying any fonts, make sure that it does not violate your licence agreement.

    1. As root, run the following commands:

cd /usr/X11R6/lib/X11/fonts/TrueType

ttmkfdir > fonts.dir

cp fonts.dir fonts.scale

    1. Close all X-windows applications and log out from X-windows.

    2. As root, restart your X-font server (or reboot your computer):

/etc/rc.d/init.d/xfs stop

/etc/rc.d/init.d/xfs start

    1. Log back onto your KDE, and from under K-menu, select "System"-"Font Manager" to see if the fonts installed correctly.

This parts is based on: http://www.computerbits.com/archive/20001000/linux0010.htm

5.3.9 How do I copy-paste?

Under X-windows, use your mouse: highlight the text to be copied, switch to the location where to copy, and press the middle mouse button to paste. This works nice and fast, as long as during the switching you don't disselect the original text. If your mouse has only two buttons (no middle button), use "both buttons together" or perhaps the right button (which combination works depends on your setup). This is the traditional "X-Windows style" copying.

Many GUI applications (but not all) also support the Mac/MS-Windows-style "copy-paste": Select the text. Use the menu item "edit"-"copy" (either from the pull-down menu, or a local menu activated with the <RightMouseButton>). Switch to the location where to copy to. Use the menu item "edit"-"paste". This works fine for applications which use the same toolkit (e.g. KDE or GNOME) but does not always work across toolkits (e.g., from a GNOME application to the KDE application).

As a keyboard shortcut for the last method, I can use <Ctrl><c> for copying the highlighted text and <Ctrl><v> for pasting. Text can be highlighted without mouse using <Ctrl><Shift><RightArrow>.

You may also use the cut-paste history. Try running klipper (in X-terminal, KDE).

The two copying methods are supposed to be separate; therefore, they should not mutually interfere.

To capture the content of a window or the entire screen to a graphics file, I use knapshot. Alternatively, I can use <Alt><PrintScreen> to take a snapshot of the current window into the clipboard, and <Ctrl><Alt><PrintScreen> to take a snapshot of the entire desktop into the clipboard.

To catch contents of a text console (outside of the GUI console), I could use in X terminal (probably as root):

cat /dev/vcs1

and then copy and paste whatever I need from the X terminal with a mouse. I need to adjust the number in "vcs1" if my terminal to capture is not terminal 1.

The text-based consoles support the mouse if you run the gpm daemon. Type gpm to test it--it will run fine if your mouse is appropriately configured. (You may want to run mouseconfig to configure your mouse.) To have gpm start automatically on the system startup and stay running, select the gpm daemon using the ntsysv utility. Use gpm exactly the same as the GUI cut-paste: highlight the text to be copied, move the text cursor to the "copy to" location, and then press the middle mouse button (or both buttons at once for a two-button mouse) to paste.

5.3.10 How do I Display and Control a Remote Desktop using VNC

(VNC = Virtual Network Computing). A very useful application--don't miss it.

VNC is a cross-platform utility that allows me to display a remote graphical desktop over a standard network connection. For example, I can use VNC on an MS Windows PC to display an X-window environment of my mighty Linux server downstairs, or the other way around. VNC will even run over a 56k modem networking, but probably only for fun or in emergency (too slow a connection for normal work).

Recent Mandrake or RH will have vnc on their distributions CD. The MS Windows version you have to download yourself. See http://www.uk.research.att.com/vnc/ for download information and more details.

On Linux, VNC consists of four commands: vncserver, vncviewer, vncpasswd, and vncconnect. I typically need just two of them: vncserver and vncviewer. A brief description of the commands follows.


The server that has to be running on the host (remote) computer. You start the server as the user whose desktop will be displayed (don't run the server as root or somebody else somebody may kidnap your computer!).


The local application which connects to the vncserver and displays the remote environment. You need to know the password and ip address of the server to connect.


Password selection utility for vncserver. The server won't run without password (good behaviour). Therefore, if you don't select one, it will prompt you. Hence, I don't need to explicitly run vncpasswd.


Tells vncserver to connect to a listening VNC viewer on the given computer and port. This way I can avoid giving anybody a password.


A "master" program that I don't really need to run directly (vncserver and vncviewer are scripts which call Xvnc).

For a list of all available options I run:

Xvnc -help

It is not recommenced to run the VNC server as root due to potential security issues. If you need root privileges, login as a user and then execute su

Two examples of "typical" sessions follow.

Example 1. Sitting at an MS Window computer, I can display an X environment from my Linux server, using the following sequence:

[start a DOS terminal and type in the following command]

telnet my_linux_server_name

[log in to your user account on Linux and type in it the following command]


[provide a really good password of your choice when prompted; mine was "357+Simon&Garfunkel"]

[re-enter the same password for confirmation]

[watch the messages and note the screen number on which the server is started; mine was ":4"]

[From the "Start" menu on the MS Windows computer, select "Programs" - "Vnc" - "Run VncViewer"

[in the input box that appears, type the server ip address and screen number as shown on the next line]


[in the input box that appears type the password as follows]


[an X-windows desktop should now appear on top of your MS Windows desktop]

[do your work as you normally would in Xwindows]

[when done, switch to the telnet session window and type in it the following two commands]

vncserver - kill :4


Example 2. Sitting at my Linux X desktop, I can display and remotely control an MS Windows computer screen. Hopefully, nobody else is using this MS Windows computer at the same time, because I move its mouse pointer.

[Walk to the MS Windows computer because you probably cannot telnet it]

[From the "Start" menu, select "Programs" - "Vnc" - "Run WinVnc (app mode)"

[From the "System Tray", click the mouse right button on the "Vnc" icon, and select "Properties"]

[In the dialog box that appears, fill in the password. Leave the screen number on "auto".]

[Walk back to your Linux desktop]

[Start an X terminal and type in it]

vncviewer ms_windows_server_name_or_ip

[When prompted, type in the password]

[a MS Windows desktop should now appear on top of your X]

[do your work as you normally would on MS Windows]

[When done, right click on the Vnc icon in the system tray and select "Close VNC".]

Suggest a Site