Published on (
 See this if you're having trouble printing code examples

FreeBSD Basics

Building an X Server and a Window Manager


This article should not be considered a substitute for the well-written, thorough instructions given in the FreeBSD Handbook starting at Chapter 12: The X Window System.

Instead, it's more of a field guide from someone who's built far too many X Servers and Windows Managers and has tried countless configuration combinations on a lot of video cards.

Building an X Server is not an exact science; there are a lot of video cards out there, and some build easier than others. You'll want to have a pencil and paper handy: If you luck out, you'll be able to record which combination of monitor, mode, and color depth worked for your video card. If the first combination doesn't work, you'll want to start systematically keeping track of what you've tried until you come across a combination that does. And if you're like me, you'll be glad you've written this down when you decide to change a working configuration to see if you can get just that little extra out of your video card.

To build an X Server, you'll need to have the XFree86 distribution installed. If you're not sure whether you installed this when you installed FreeBSD, try this:

cd /usr

In the resulting list, you should see a directory called X11R6, which should have a subdirectory called bin.

You also need to know the chipset of your video card. As root, run the SuperProbe utility to find out this information:

cd /usr/X11R6/bin

Which will return something like this:

SuperProbe Version 2.21 (12 October 1999)
  (c) Copyright 1993,1994 by David Wexelblat <>
  (c) Copyright 1994-1998 by The XFree86 Project, Inc
  This work is derived from the '' and
  '' documentation packages produced by 
  Finn Thoegersen, and released with all appropriate 
  permissions having been obtained.  Additional 
  information obtained from 'Programmer's Guide to 
  the EGA and VGA, 2nd ed', by Richard Ferraro, and 
  from manufacturer's data books
Bug reports are welcome, and should be sent to In particular, reports of 
chipsets that this program fails to correctly 
detect are appreciated. Before submitting a report,
please make sure that you have the latest version 
of SuperProbe (see

First video: Super-VGA
  Chipset: Trident GUI 9680 (PCI Probed)
  Memory:  1024 Kbytes
  RAMDAC:  Trident Built-In 15/16/24-bit DAC
           (with 6-bit wide lookup tables 
           (or in 6-bit mode))

Record your chipset information, as you need to know this to configure your X Server.

The memory information is useful in determining which color depth you will choose. Because I only have 1 MB of memory on this video card, I'm limited to 8 or 16 bits per pixel (bpp). If your video card has 2 or 4 MB, you should be able to use 24 bpp; you'll probably need 8 MB for 32 bpp.

I've had a few older video cards for which SuperProbe was unable to find information; this is not a good sign of an easy X Server build. There is a card option for Unsupported VGA compatible that will build with the standard VGA monitor, but it looks horrible.

If you are building X Server when you install FreeBSD, you can use Alt-F4 to receive a prompt so you can run SuperProbe. Once you've recorded your information, return to Alt-F1 to continue with the setup utility.

Lastly, if you will be using the graphical X Server configuration utility, it is easier to configure your mouse beforehand using /stand/sysinstall. Conversely, if you're using the non-graphical configuration utility, it is easier not to configure your mouse first.

If you've already installed FreeBSD, root can access the graphical X Server configuration utility by either of these methods:


and from there choose Configure, then XFree86, and then XF86Setup


cd /usr/X11R6/bin/XF86Setup

Most video cards support the graphical setup utility, which presents you with a point and click interface. Also, if you highlight a card in the Cards screen, you can use the Read README file button to view the readme document for that chipset.

Some cards don't support the graphical utility; again, this is not a good sign of an easy X Server build. If you have one of these cards, you'll have to use the xf86config utility instead, which is also found in /usr/X11R6/bin and /stand/sysinstall. This utility will ask you questions that require a type-in response. To find the readme for your chipset, open up another virtual terminal and look in


Let's assume you've started the graphical configuration utility with a working mouse, clicked on the Card button, and highlighted the card that SuperProbe told you you have. Later on, you can be a power user and fine-tune all of the settings in the Detailed Setup button, using the information supplied in the readme document for your video card. For now, we'll keep the default probes until we're sure we can successfully build the X Server.

Now comes the part that requires a bit of luck if you've never built this type of video card before: the monitor and modeselection screens. Most newer video cards will run on a combination of Extended Super VGA at 800 x 600 and 16 bpp, so I always try this combination first. If it works, I build a Windows Manager, see if it looks satisfactory, and possibly tweak my settings from there. If it doesn't work, I take a closer look at the video card's readme file for hints, and start recording which combinations I've tried til I hit one that works.

If you still have problems building X Server or want hints in tweaking your X Server, the FAQs at xfree86 are well worth reading.

Once you have built X Server, you'll want to start customizing your desktop environment. If I type startx on a fresh X Server, the resulting windows may prove functional, but they look awful. If you're unsure which window manager to install, Matt Chapman's Window Managers site is an excellent resource that provides screenshots of the most popular window managers and desktops.

If you like simplicity, configurability, and a clean look to a desktop, Windowmaker and XFCE are good choices. They also perform well on older video cards and computers with as little as 16MB of RAM.

If you have a new video card and lots of RAM and like a desktop with the works, KDE or Gnome was meant for you.

The hardest part of building a Window Manager is deciding which to install. I like to build a new one every month, which gives me time to become acquainted with its features so I can rate it on looks, configurability, and performance. Every Window Manager has its own unique features you'll find you can't live without, as well as some irritating glitches you wish someone would fix.

If you configured your X Server in /stand/sysinstall, you'll be given the option to configure your desktop with a choice of KDE, Gnome, Afterstep, Windowmaker, or fvwm2. If you choose one of these, the installation will configure the desktop for root; once it's finished, you can open another virtual terminal, login as root, and type startx to see your new desktop.

To return to your other virtual terminals, use Ctrl-Alt-Fx where x is the number of the terminal you wish to access. To return to your terminal running X Windows, use Ctrl-Alt-F9. If you have two X Windows desktops running, you'll find the second one hiding at Ctrl-Alt-F10.

The file that contains the command to execute your Windows Manager is .xinitrc. If you type:

more /root/.xinitrc

you'll see that /stand/sysinstall created the necessary entries for you. If you want other users to use this Windows Manager, you'll need to copy this file to their home directory like so:

cp /root/.xinitrc /usr/home/username

If you build a Windows Manager from a package or port, or wish to have different users using different Windows Managers, you may have to edit .xinitrc by hand. Make sure you store .xinitrc in that user's home directory.

For Windowmaker, you'll need the line:exec wmaker
For Gnome with Afterstep:gnome-session &
exec afterstep
For XFCE:exec xfce

This should get you started with a Window Manager. In our next article, we'll look at configuring the Window Manager XFCE in more depth.

Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.

Read more FreeBSD Basics columns.

Discuss this article in the Operating Systems Forum.

Return to the BSD DevCenter.


Copyright © 2009 O'Reilly Media, Inc.