Linux: Configure Xorg X11 Window System

My xorg.conf file is missing as I deleted accidentally for some reason. Now, Xorg try to probe my hardware on every startup. How do I configure Xorg under Debian or any Linux distro / operating systems?

The latest X server versions are designed to work out-of-the-box, with no need to manually edit Xorg’s configuration files. However, you can use the following generic steps to edit or create xorg.conf file.

Stop X Windows Manager

First, you need to shutdown X and its manager. The simplest way to do is login to a console as root and type the following commands to stop kdm or gdm:
# /etc/init.d/kdm stop <-- stop KDE windows manager # /etc/init.d/gdm stop <-- stop Gnome windows manager # /etc/init.d/xdm stop <-- stop x windows manager

How Do I Configure X?

You can type any one of the following command:
# dpkg-reconfigure xserver-xorg
The above is Debian / Ubuntu Linux specific command. The generic command for Linux and UNIX is as follows to configure X:
# cd /etc/X11/ && Xorg -configure
Now, just follow on screen instructions to configure Xorg. You can configure Video (mostly auto detected), keyboard and so on.

Testing new config

The above command will create a new Xorg conf file. You can test with the following command:
# X -config -retro /root/
# X -config -retro /etc/X11/xorg.conf

If everything looks good, try startx to start up your X server (swtich to another virtual console (Ctrl + Alt + F2) and type the following command):
$ startx

Fine Tuning Xorg

You can edit /etc/X11/xorg.conf to make changes such as setting a new driver, adding fonts path, video resolution and so on.
# cp /etc/X11/xorg.conf /etc/X11/xorg.conf.working
# vi /etc/X11/xorg.conf

In this example, set video size to 1440x900:

Section "Screen"
  Identifier  "Default Screen"
  Device    "RadeonHD 4550"
  Monitor   "Generic Monitor"
  DefaultDepth  24  
  SubSection "Display"
    Depth   24
    Modes   "1440x900"

Save and close the file. You need to restart or reload X to see changes.

Xorg log file

You can see error or warning log file for troubleshooting purpose at the following location:

  • /var/log/Xorg.?.log

Use the tail or grep command to view log file:

tail -f /var/log/Xorg.2.log
grep 'something' /var/log/Xorg.2.log

Recommend readings:

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.