Setting up X on Slackware


3rd September 2001

updated 26th May 2004

Until a few years ago, setting up X was my biggest problem with getting a new Linux installation working. However the last few years have seen great improvements and a large amount of simplification of the configuration files. Slackware 8.0 and upwards have proved to be very easy to get X going. Originally, I wrote a set of notes for someone new to it, and put them here. They have proved popular, so I have upgraded them a little.

I don't like to do a Linux installation and have it boot straight into X for a GUI login. If you haven't setup X properly, then you can never boot and log in. I set it up initially for command line logging in, then I get X working properly, and only then do I set it up for the GUI logon.

For these instructions, I assume that you have installed Linux, with all the X packages, and you can login at the command line.

Required packages

During installation, you will have been given a lot of choices. In Slackware, the packages you need are

  • X = the X Window System
  • XAP = X applications

The two optional packages are

  • KDE
and you will probably find these packages on the second Slackware installation cdrom.

If you didn't install X and XAP, you will need to go and install them. If you want Gnome or KDE or both, go back and install the Gnome and KDE packages. I usually install both Gnome and KDE because I like to go and look at them occasionally, and show them off to other people, and disk space is not a problem. I don't actually use the desktops, as I prefer my configuration of fvwm2, but I do use some of the Gnome or KDE programs under fvwm2. Once these are installed, you can continue.

X components

The X Window System is a two tiered structure.

  1. At the bottom level is the X Server. This controls the low level stuff like the graphics card, the keyboard and mouse. Linux uses a free version of the X Server called XFree86.
  2. On top of the server is the Window Manager. This controls the way windows look, the way title bars look, that sort of thing. There are quite a number of these available. You can choose the one you want, work with it a while, replace it if you like, and keep fiddling until you find one that works the way you like. and many more. If you want to look at the different ones available, go to the Window Managers for X web site.

I use fvwm2 for my window manager because it lets me do everything I need, it's configurable through one simple text file (none of this mouse/menu configuration stuff), it's fast, doesn't use much memory, and I'm used to it. Yes, I have tried other window managers, but I keep coming back to fvwm2. In 2003, I tried Blackbox, and a derivative called Fluxbox. These were really nice window managers. Very fast, low memory usage, lightweight, and very very pretty. The themes, and the easy configuration caused me to switch to them for a few months. However the functionality of fvwm2 drew me back, and I learnt how to make themes for fvwm2 and how to make fvwm2 just as pretty as Blackbox and Fluxbox.

There is often an optional third layer on top of this, and that's the Desktop. This provides lot of applications and utilities and applets and GUI configuration tools. There are a couple of these around:

  • CDE (Common Desktop Environment)
  • KDE (K Desktop Environment)
  • Gnome (GNU Network Object Model Environment)
  • XFce (?)

You don't have to run a Desktop. I generally don't. But you can if you want to. These are sometimes described as Window Managers, and are offered instead of Window Managers in installation menus, but they aren't. Underneath them is still a Window Manager, even if they try and hide it.

Your job is to get each of these 3 levels configured and working. The first level, the X Server, can be tricky. The other two are very easy.

Configuring the X Server

To get the whole process started, we have to configure the X-server. To do this we have to supply the details of your hardware:

  • the keyboard
  • the mouse
  • the video card
  • the monitor

You are probably using a standard mouse and keyboard so that won't give you any grief. It's the video card and monitor that often frustrate people. What you should do before you start is make a note of what make and model your video card is. For your monitor, make a note of the make and model, and look through the manual, or search the manufacturer's website for details about the horizontal and vertical refresh rate. Don't get too upset if you can't find this. If you can find it, you'll get more precise control of the system, but if you can't, you can still run X.

First you must log on as root. X configuration is done at root level. Then there are two paths you can go by, depending on your version of XFree86.

  • If you are using versions of XFree86 earlier than 4, then use the old method of configuring the system by answering a lot of questions, using "xf86config".
  • If you are using versions of XFree86 4 or greater, then use X's self-configuration mode. X will try to recognise the components you have, with "X -configure".
Both methods will create an initial configuration file for X, which you can fine-tune later.

"xf86config" for earlier XFree86

  • Type "xf86config". This is a primitive command line utility that will ask a bunch of very confusing questions. Most of the questions can be answered with the defaults.
  • The hardest questions will be about your monitor. Look in your monitor manual and try and find this information. If that fails, search the Internet for the manufacturers specs on your monitor and look for the H and V refresh rate. If that fails, use H = 30-50 and V = 50-90. Use the options that let you type in your own values. These will get you going, and can be fine tuned later.
  • There is a database of video cards. Yours should be in it, if you know what it is. If not, look for Generic SuperVGA. Don't worry about the amount of memory on the card. Most cards today have more memory than is offered on this screen, and xf86config doesn't like anything over 4 meg anyway. Besides, the X Server will recognise how much memory is on your card and use it without you having to specify it.
  • Choose defaults for most of the rest of the stuff. All this is trying to do is create a text config file that you can fine tune later. We want to create a basic copy that will get us started.
  • Get to the end of the questions and let xf86config create the configuration the file. It will save it as /etc/X11/XF86Config. Go and have a look at the file. That file is full of gunk, isn't it? Looks confusing. I've trimmed mine right down to the bare minimum. I've got it here for comparison. Yours will probably contain a lot of helpful information. Read through it and try and make sense of it.

"X -configure" for XFree86 4+

  • Run "X -configure".
  • This will blank the screen for a bit while it does an analysis of your system, and then it will create a new configuration file in /root/ It also produces output on stdout that is worth reading.
  • Take that configuration file, check it out, and then move it into position at /etc/X11/XF86Config.
  • Have a look at a sample one I have created. You can see that it produces very different output to the one created by xf86config.
  • You will need to edit it before it's useful. Change these things:
    • Section "Monitor": add descriptions and make and model, and then add two lines for the HorizSync and VertRefresh. Refer to your monitor manual or Google for these results, or if you can't get the details, start with basic values like
            HorizSync    30-50
            VertRefresh  50-90
    • Section "Screen": this needs a lot of fleshing out. Each of the Subsection "Display" blocks needs lines added: Modes and ViewPort. Easiest way to start is to add
              Modes       "1024x768" "800x600" "640x480"
              ViewPort    0 0
    After editing, it should like something like this file.

Testing XF86Config

Okay, now let's test your config file. Change back to root's home directory. Stay logged in as root. Type "startx 2> x.log". You'll get one of four outcomes:

  • X will start up and a Window Manager or Desktop will run. This is success.
  • X will start up, then drop back immediately to the command line. Look in the file x.log for the errors. Also look in the log file /var/log/XFree86.0.log for problems. You need to correct the errors and try again.
  • X will start, and all you get is a grey screen and nothing else. Press Ctrl-Alt-Backspace, and you will drop back to the command line. Examine the files x.log and /var/log/XFree86.0.log, and work out what your errors were and fix them and try again.
  • Your monitor implodes, a faint cloudy gas wafts out from what was left of your monitor, and broken glass lies on your desk. Buy another monitor, correct your horizontal and vertical refresh rates, and try again.

When you achieve success, exit back to the command line.

Fine-Tuning the X Server Configuration

That should get you going. You won't be happy though. There is fine tuning required to get the screen to look good and to work at the resolution you probably want. That is all done by hand editing the file /etc/X11/XF86Config. Use mine as a reference. The important section to look at is the Screen Section at the end.

Here is my Screen Section:

Section "Screen"
    Identifier  "Screen 0"
    Device      "Card0"
    Monitor     "Monitor0"
    DefaultDepth 24

    Subsection "Display"
        Depth       8
        Modes       "1024x768" "640x480" "800x600"
        ViewPort    0 0
    Subsection "Display"
        Depth       16
        Modes       "1024x768" "640x480" "800x600"
        ViewPort    0 0
    Subsection "Display"
        Depth       24
        Modes       "1024x768" "640x480" "800x600"
        ViewPort    0 0

There are several things that I fiddle with - the default colour depth and the resolution order.

Default Colour Depth

I set the default colour depth to 24 (DefaultDepth 24). That gives me plenty of colours and doesn't slow the system down. The range of depths is:

  • 1 (2 colours = black and white)
  • 4 (16 colours)
  • 8 (256 colours)
  • 16 (65,546 colours, equivalent to "High Colour" on Microsoft Windows)
  • 24 (16 million colours, equivalent to TrueColour24 on Microsoft Windows)
  • 32 (4.2 billion colours, equivalent to TrueColour32 on Microsoft Windows)

You should be able to discover the mathematical progression in that list.


I like to have my screen running at 1024 x 768 pixels. To set that up, I edit XF86Config. I go to the Screen section, and choose the Display Subsection that matches my DefaultColourDepth. Then I edit the Modes line, so that "1024x768" comes first. The first one in that line is what the X Server will start up with. Each time you press Ctrl-Alt-Num+ it will advance to the next one on the line. Each time you press Ctrl-Alt-Num-, it will move to the previous one. So set them up in with the one you want to start with in first place, and the rest in the order that you want to move through.

Type "startx 2> x.log" and test it. Test that it starts with the one you want and that they move in the right order. If it doesn't start in the right one, or misses some when you move through the list, exit and check the log file x.log. You'll probably find that your video card/monitor combination isn't set up to handle the missing combinations. The log file will show you what's wrong. You can correct XF86Config and try again.

Mouse Adventures

These days it's impossible to buy a decent three button mouse. All you can get are two button mice with a scroll wheel where the middle button should be. As a sop, you can click down on the scroll wheel and get the middle mouse click. I loathe these things. I absolutely hate scroll wheels. I want a decent three-button mouse, with no scroll wheel. Logitec used to make them, but now pander exclusively to the Windows world. Thankfully, eBay still digs up the old Mouseman and I stay in stock.

However, most people have scroll wheels on their mice, and want to use them. You can do it with X too. It's been documented by others, so try these sites:

Further Reading

If you want to get into all this some more, then you should do some reading. Your reading should start with "man XF86Config". Then try the brief HOWTO written by Eric Raymond, found in Slackware at /usr/doc/Linux-HOWTOs/XFree86-HOWTO. Then use Google and STFW.

Then read some other books like:

  • Running Linux, Matt Welsh et al, O'Reilly
  • XFree86 For Linux, Aron Hsiao, QUE

If you want to get heavily into the video timings and get a deeper knowledge of such things, you should read Eric Raymond's HOWTO about video timings, found in Slackware at /usr/doc/Linux-HOWTOs/XFree86-Video-Timings-HOWTO.

Setting up graphical login

Now that the X Server is running, the next thing to do is shift to a graphical login so you can choose your Window Manager, and then you can start configuring it.

What you want now is to have an automatic graphical login. That is, when you boot into Linux, you don't get a command line, you get a nice fancy graphical screen, and you can login and choose your Window Manager on the fly.

  • Login as root.
  • Change directory to /etc.
  • Edit the file inittab.
    • Go down till you find a line that looks like "id:3:initdefault:".
    • Change this to read "id:4:initdefault:".
    • Save the file.
  • Shutdown and reboot with "shutdown -r now".

NOTE This is for Slackware. With Slackware, runlevel 4 starts graphical login. On other Linux distributions, a different runlevel is required.

From now on, when Linux starts, you will get a graphical login screen. This could be one of three programs:

  • xdm
  • gdm
  • kdm

Which one is used? You've changed the default boot process from runlevel 3, to runlevel 4. So look in /etc/rc.d and have a look at rc.4. This startup script shows which login program will start first. It tries gdm, then kdm, then xdm and then gives up. That is, it tries GNOME's gdm first. If it doesn't find it (maybe you didn't install the Gnome desktop), then it tries KDE's kdm. If that doesn't exist (maybe you didn't install KDE) then it tries the old standby xdm. And if that doesn't exist (maybe you deleted it in a fit of pique), then it says that you can't use runlevel 4 without one of those three programs installed, and then it will reboot. It will probably reboot and reboot until you do something tricky like forcing a runlevel 1 boot, and changing inittab's initdefault back to runlevel 3.

If you want to force use of kdm, or gdm or xdm, then edit /etc/rc.d/rc.4 and change the script to do what you want it to do.

xdm is a legacy of the past. It's primitive. You get to enter your logon name and password, and then a Window manager starts up. This is controlled by your $HOME/.xsession, or if you don't have one, by the default /etc/X11/xdm/Xsession. Have a look at this file to see how it's done. It's interesting. xdm can be configured quite a lot, by editing /etc/X11/xdm/xdm-config. Use 'man xdm' as your starting point. I think you can even set it up to choose which Window Manager. If you want to know more, check out these books. They have large chapters on xdm and its configuration.

  • The Concise Guide to XFree86 For Linux, Aron Hsia, QUE
  • X Window System Administrator's Guide, Linda Mui and Eric Pearce, O'Reilly

gdm is an adequate graphical logon. You can configure it on the fly, by selecting Session -> Configure, and entering your root password, and then fiddling with all the options. You can choose which window manager to use at each logon. I don't like the logon name and password on different screens, and I don't like the positioning of the window manger choice. Too many steps. But that's just my prejudices at work. You might prefer it like that.

kdm is the default graphical logon for Slackware. It's the second choice in /etc/rc.d/rc.4. I prefer to use it, so I edit the file and make it the first choice. You can organise rc.4 to suit yourself. I prefer kdm because I like how I can enter logon, password and window manager choice very cleanly. Configuration is done the way I like it. You edit a text file. Edit the file /opt/kde/share/config/kdm/kdmrc. I usually change it so that it doesn't show the heads and list the logon names, replaces the KDE logo with a clock, and I change the greeting to something like "astoria on Henry's Network", where astoria is the host name of my machine.

So I stick with the KDE graphical logon, kdm, and this lets me enter my name and password and choose which Window Manager or Desktop I want to work with.

When you do get to kdm or gdm, you'll notice that they will offer both Desktops and Window Managers as Window Managers. That's okay. The Desktop options will automatically start whatever Window Manager they favour this month, and then insert themselves on top.

Configuring the Window Manager

Each Window Manager (and Desktop) is configured completely differently. I'll leave that as an exercise for the reader. However, I'll include my .fvwm2rc so you can see how I configure that to suit my needs. This file used to be stored in my home directory, but the latest version of fvwm2 expects to see it located in $HOME/.fvwm/.fvwm2rc, so I store it there now.

You'll notice that all the menus I use have no little icons attached to them. With fvwm2, you can put a mini icon on every menu, if you are visually inclined. However, I learnt to read as a child and have no need for such reminders. I removed them all. All my menus are text, small, and slick. I don't have to worry about finding a whole bunch of small silly icons and making them available in the right paths.

If you use the Gnome or KDE Desktops, or pretty much any of the Window Managers, you can attach little icons to almost anything, customising your window environment way past the useful stage.