# [How To] Editing The Xorg .conf File



## Satissh S (Nov 29, 2005)

In the way of my life with linux, as everyone, i have faced a lot of troubles, but each trouble of mine proves to be a stepping stone to attaining a higher level of understanding of this wonderful operating system. I had to learn deep about X when i had to setup my cards and other x components working. 
Editing the xfree86.conf or xorg.conf file to get one's graphics card working is one of the biggest hurdles for a linux newbie. Only if he could understand what he is doing, he could get rid of the fear that holds him back. The purpose of this article is just that 
Basically the afore mentioned files address to three types of settings.

1. Global Settings - X Settings.
2. Device Specific Settings.
3. A structure Sectional layout that combines the above two.

*  The Structure :  *
The Xorg.conf (I will be referring only to this file whilst the same holds true for the other as well) is basically structured into different sections.
Like this,
* Section * _Name used to identify the device_ /*Start of the Section**/
* Device * _Name of The Device _
* Driver * _The driver that x loads to run the device _
* Option * _Different Options and parametres for the device _
* EndSection * /*End of the Section **/

In addition to the above sections there are special sections or device specific settings that one can configure.

*  The Base Sections :  *
Here are a few basic sections that are found in the xorg.conf files and their functions.

*  1. ServerLayout:  *
* Section * _ServerLayout_ /*Start of the Section**/
* identifier * _ Single head configuration _ or _ multi head configuration _ /*If you have multiple displays on different graphics cards multi head mode is used otherwise, Single head mode will be used**/
* Screen * _0        "screen0" 0 0 _ /* This Section identifies that a screen named screen0 is where x will run. In single mode configurations the screen is usually denoted as   0 0 whereas if in multihead mode, it'll be different and the identifier for the second screen would be screen1. **/
* InputDevice * _Name of The Device _ /* Specifies the input defices and their identifiers eg:"Mouse0" and its parametre "core pointer" which it is set to*/
* EndSection * /*End of the Section **/


*  2. Screen Configuration : *

* Section * _Screen_ /*Start of the Section**/
* Identifier * _"Screen0"_
* Device * _"Videocard 0" _ /* Refers to the Section Videocard **/
* Monitor * _"Monitor 0" _ /* Refers to the Section Monitor **/
* DefaultDepth* _<integer representing the bits of depth of color (eg: 16, 24)>_ 
*Subsection* _ "Display" _ /* Section Within the Current Section **/
* Depth * _<integer representing the bits of depth of color (eg: 16, 24)>_
* Modes * _< Different Resolutions For the above Depth >_
*EndSubSection * /* Ends the Subsection **/
* EndSection * /*End of the Section **/

*  3. Mouse Configuration : *

* Section * _ "InputDevice" _
* Identifier * _ "Mouse0" _
* Driver * _ "mouse" _
* Option * _ <options> _
* EndSection *

The Options include,
1. *Protocol* to Specify your protocol such as "IMPS/2" or "PS/2" or "usb" as parametres to the protocol option.
2. *Device* to Specify where the Device is connected to, Such as "/dev/psaux" for PS/2 for Serial Mouse /dev/ttyS0 for COM1 Port.
3. *ZAxisMapping * to set wheel motion for a wheel mouse as "int int"- two integers specifing the motion of the wheel.

*  3. Keyboard Configuration :  *

* Section * _ "InputDevice" _
* Identifier * _ "Keyboard0" _
* Driver * _ "keyboard" _
* Option * _ <options> _
* EndSection *

The Options Include,
1. *XkbLayout* to specify a keyboard layout an "us" or any other layout.
2. *AutoRepeat* to specify the number of times keys will be repeated as two options, <Delay time before a key that is held down starts repeating> <number of times the key is repeated per second>.
3. *XkbModel* Specifies the keyboard model such as pc101 , pc102 or microsoft .

* 4. Monitor Configurations : * 

* Section * _ "Monitor" _
* Identifier * _ "Monitor0" _
* VendorName * _ "<Monitor Vendor>" _
* ModelName * _ <Model Name> _
* HorizSync * _<Horizontal refresh rates>_ /*          Specify your horizontal refresh rates here **/
*VertRefresh* _<vertical Refresh Rates_ /* Specify your vertical refresh rates here **/
*Option* *"dpms"* /* The DPMS option specifies whether you want to use the powersaving features of the monitor. It supports standby and suspend functions **/
* EndSection * 

* 5. VideoCard Configurations : * 
* Section * _ "Device" _
* Identifier * _ "VideoCard0" _
* Driver * _ "<Name of the driver>" _ /* nv , vesa ,nvidia etc., **/
* VendorName * _ <Name of the Vendor> _ /* Name of the Card **/
* BoardName * _ <Name of the Board> _ /*Name of the board of the Card **/
* EndSection *
* Note About Vesa Driver: *
Vesa Stands for Video Electronics Standards Association (VESA). You can get your unsupported graphics card to work if you can specify vesa in the driver section and later install the appropriate driver and update the xorg.conf file. 

* 6. Module Configurations : * 
When X Server Starts up it looks for the following section for knowing the modules it has to load.
* Section * _ "Module" _
* Load * _"dbe"_
* Load * _"extmod"_
* Load * _"fbdevhw"_
* Load * _"glx"_
* Load * _"record"_ 
* Load * _"dri"_
* Load * _"freetype"_
* Load * _"type1"_
* Load * _"xtt"_
* Load * _"speedo"_
* EndSection *

* Explanation of Modules:*
1. dbe: 
Required for animations. Implements Double buffering for flicker   free and smooth of animations.

2. extmod:  
Loads module for performing common functions in X Server.

3. fbdevhw:
The Linux framebuffer module which is used to let x communicate with framebuffer device in linux.(/dev/fb0)

4. glx:
The glx extension connects the DRI 3D library and X. 
the following command gives you information about glx and the fps at which xserver functions:-
#glxgears -info

5. record:
The record module adds record extension to capture events that are associated with recording and playback user actions.

6. dri:
Loads Direct Rendering Interface to provide accelerated 3d graphics. * NOT SUPPORTED BY NVIDIA CARDS *

7. freetype:
Loads the module that can handle TrueType (.ttf and .ttc) ,Type1 (.pfa and .pbf) and OpenType (.otf and .otc) Fonts

Additionally there can also be another section called DRI
* Section * _"DRI"_
Mode 0000 /* Specifies the mode in which DRI will run Eg: 0666 etc., **/
* EndSection *

The Above Mentioned are the prime sections of the xorg.conf file which can be edited to your preferences. Hope the above was useful  
Any Corrections, Suggestions and tips will be gleefully acknowledged. 
The Document is licensed under Free Document Licence and FSF.


----------



## GNUrag (Nov 29, 2005)

Very nice tutorial, this one deserves to be sticky, if you've written it. 

btw, i'd appretiate if you could give some info on VESA mode. As this is a life saviour if graphics card isnt supported.


----------



## Satissh S (Nov 29, 2005)

Yes, Promise You, I wrote it, but i'm just a beginner in linux. I had to learn the above from various sites such as tldp.org and google searches when i was trying to configure my Nvidia GeForce 6800 GT card. And also when trying to get x working with Gentoo.

VESA:-
Vesa Stands for "Video Electronics Standards Association". I used this driver with my nvidia card b'coz, the card was relatively new and wasn't suported i guess. Later I installed NVIDIA Drivers. I think All Graphics hardware supports VESA driver. 

PS: Was there anything wrong in what i wrote?  :roll:


----------



## vignesh (Nov 29, 2005)

Good tutorial mate.... 

My card is Nvidia geforce 2.When I tried installing Xandors.The installation screen never showed up.I even tried the VESA setup...but no luck.You are saying that all graphics hadware supports VESA...


----------



## Satissh S (Nov 29, 2005)

But Vignesh, why don't you remove the card and try installing xandros, and once installed later pluggin the card. Xandros has nvidia drivers and will support them. Correct me if wrong.. But i'm pretty sure that vesa driver supports all cards, atleast until you install the drivers.


----------



## desertwind (Nov 29, 2005)

Excellent tutorial. I must appreciate your work.

Way to go Satissh


----------



## vignesh (Nov 29, 2005)

Its an onboard graphics card...


----------



## mehulved (Nov 30, 2005)

Good work satish.


----------



## cnukutti (Dec 2, 2005)

Nice tutorial.
_____________
*feeds.feedburner.com/fslog.gif


----------



## praka123 (Dec 7, 2005)

Very Nice HOWTO Sateesh.You mentioned u tried installing Gentoo...why not show us brief steps of how do you achieve that..


----------



## Satissh S (Dec 8, 2005)

Here'tis prakash! Much of these i had learnt from the handbook and followed them just like that. Once you have setup your netcard, you can fireup links2 and refer to their manuals. 
1.) Boot into gentoo minimal install live cd.
2.) Set the date, 
* date 120722352005 * /*Me typing at 07th december 10'o clock (pm) 35 minutes and year 2005 */

3.) Set-up ethernet card. 
* net-setup eth0 *
 From here on I simply followed the instructions from :-
 Gentoo Handbook  
It can be easily done by opening another shell [ctrl]+[alt]+*
and opening * links2 *. I referred the guide and executed the commands back and forth.

4.) Execute fdisk to partiton hard disks.
fdisk /dev/hda /* /dev/hda is the first hard disk and /dev/hdb is second and so on.. */

5.) P for partition information and use fdisk to create and resize partitons. Tap m to see the list of commands.
I made the foll,
/dev/hda1        Ext2 Filesystem to be mounted for /boot
/dev/hda2        Swap
/dev/hda3        ReiserFs as /      

6.) Now,
* mke2fs /dev/hda1 *
* mkswap /dev/hda2 *
* mkreiserfs /dev/hda3 *

7.) Turning on the swap,
* swapon /dev/hda2 *

8.) For my nvidia card:-
* modprobe nvidia *

9.) mounting the root partition as /mnt/gentoo
* mount /dev/hda3 /mnt/gentoo *

10.) mounting the boot partition as /mnt/gentoo/boot
* mount /dev/hda1 /mnt/gentoo/boot *

11.) Downloading the Stage 3 tarball 
1.) From the net:-
* cd /mnt/gentoo *
* links2 *www.gentoo.org/main/en/mirrors.xml * 
I navigated to the architecture and pressed *D* to download. And the * Q * to quit links2.
* tar xvjpf stage3-pentium4-* * [tab]
2.) From CD(Gentoo Universal CD):-
* mount /dev/cdroms/cdrom0 /mnt/cdrom *
* cd /mnt/gentoo *
* tar xvjpf /mnt/cdrom/stages/stage3-pentium4-2005.1-r1.tar.bz2 *

PS; Substitute pentium4 with u'r architecture.

12.) Installing Portage Snapshots:-
* links2 *gentoo.osuosl.org/snapshots/ *
Download the snapshot and then untar it.
* tar -xvjf portage-2005*.tar.bz2 -C /mnt/gentoo/usr * 

13.) Mounting /proc and /devfs filesystems
* mkdir /mnt/gentoo/devfs
mkdir /mnt/gentoo/proc 
mount -t devfs devfs /mnt/gentoo/devfs
mount -t proc none /mnt/gentoo/proc
*

14.) Copy the resolv.conf so that you don't have to set-up net again
* cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf *

15.) Optimising the environment variables using /mnt/gentoo/etc/make.conf :-
* nano /mnt/gentoo/etc/make.conf *
Here 
Donot edit CHOST Setting 
Set CFLAGS to -march=i686 or -march=athlon-xp
we can use -O pipe and speed optimisation flags (0 ,1,2,3). I really dunno abt these, seem like compiling options,
example, 
* CFLAGS="-march=i686 -pipe -O2" *
* CXXFLAGS="${CFLAGS}" * /*To use Same Setting as CFLAGS**/
* MAKEOPTS="-j2" * /* Number of parallel guidelines to occur. Value = No. Of CPU + 1 **/
Next we have to configure our portage setting. There were several options in the make.conf.example which i don't remember now. Open the File in another terminal. Select the option you wan't and [click] to paste in your make.conf file. Finish. *  :ws * for vi , * [ctrl] + x * to quit in nano.

16.) Using mirror select to select mirrors:-
* mirrorselect -a -s4 -o | grep GENTOO_MIRRORS >> /mnt/gentoo/etc/make.conf *
Double checkin /etc/make.conf for changes.

17.) Changing root directory to /mnt/gentoo using chroot:
* chroot /mnt/gentoo /bin/bash *

18.) Updating Environment Variables:-
* env-update; source /etc/profile *

19.) updating the portage information:-
* emerge sync *
* emerge --metadata * /* Speeds up emerges by building a portage cache**/

20.) Configuring USE Variable:-
We have to configure /etc/make.conf with the use variables.
view the _* /usr/portage/profiles/use.desc *_ file for available use flags. 
* USE="gtk gnome -qt -kde dvd alsa cdr" * 
The above line specifies to use gtk , gnome dvd alsa and cdr and not qt and kde. If you want you can put -gtk and  -gnome and use qt and kde.
Add the following for kernel sources package 
* USE="-doc" emerge gentoo-sources *

21.) BootStrap the Gentoo root partiton:-
* cd /usr/protage/ ; scripts/bootstrap.sh * /* Dunno why should this be done. **/

23.) Set TimeZone:-
ln -sf /usr/share/zoneinfo/_<path> _ /etc/localtime /** path area should be your timezone. I dunno what to put there i simply put */IN/South * Dunno if correct.

24.) modify fstab:-
* vi /etc/fstab *
_ /dev/hda1[tab]/boot[tab]ext2[tab]noauto,noatime[tab]1 2
/dev/hda2[tab]none[tab]swap[tab]sw[tab]0 0
/dev/hda3[tab]/[tab]reiserfs[tab]noatime[tab]0 1
/dev/cdroms/cdrom0[tab]/mnt/cdrom[tab]auto[tab]noauto,user[tab]0 0
/dev/cdroms/cdrw0[tab]/mnt/cdrom1[tab]auto[tab]noauto,user[tab]0 0
none[tab]/proc[tab]defaults[tab]0 0
none[tab]/dev/shm[tab]tmpfs[tab]defaults[tab]0 0 _

25.) Building the Kernel:-
I choose to get my kernel by using genkernel as i was a bit afraid of building it myself  
* emerge gentoo-sources * /* D/L Gentoo Source **/
* emerge genkernel * /* D/L GenKernel **/
* genkernel --menuconfig all *
* ls /boot/kernel* /boot/initramfs* * /* For Kernel name and the initrd generated **/
* emerge coldplug * /* D/L coldplug for autodetection of hardware and other components **/
* rc-update add coldplug boot * /* Adding coldplug to run at boot **/

26.) Adding some Extra- Services:-
*emerge syslog-ng
rc-update add syslog-ng default
emerge vixie-cron 
rc-update add vixie-cron default
emerge hotplug
rc-update add hotplug default
emerge reiserfsprogs
rc-update add reiserfsprogs default
rc-update add domainname default
* Runs System services such as system logger, cron daemon , hotplug , reiserfs daemon , domainname.

27.) Add Driver Support.
emerge nvidia-kernel

28.) Add users:
1. Set root password:-
passwd

2. useradd _<name>_ -m -G users,wheel,audio -s /bin/ash
passwd _<name>_

3. Machine Name:-
echo _<name>_ > /etc/hostname
echo _<name.com>_ > /etc/dnsdomainname

29.) Configure Grub:-
* emerge grub *
* grub * or manually edit /etc/grub/menu.lst

30.) Reboot and install packages:-
* emerge -k xfree(or xorg) gnome mozilla openoffice-bin *
Let them D/L and you have all that you need to get your system working. Of Course we need to configure xserver. Run xorgconfig or xf86config.
Hope the above was useful. Correct any mistakes please. ​


----------



## Satissh S (Dec 8, 2005)

@prakash: BTW I'm gonna install debian soon. Have ordered the two dvd's and will be installing them soon.


----------



## praka123 (Dec 8, 2005)

Thanks for yet another review.I am going to install gentoo 2004.3(thats wat i got) this week or probably next week.U enjoy debian..  
b/w i have got universal install CD..so i think no need to download extra snapshots.....or is it necessary?whether U compiled Ur own kernel or genkernel...Thanks


----------



## Satissh S (Dec 9, 2005)

No we don't have to download stages btw, we have to d/l snapshot b'coz when using emerge we have to have configure repos i guess.. I used genkernel as iam a bit afraid to do it myself but it has been explained very elaboratly in the handbook. Enjoy Gentoo.. meanwhile lemmy dive into a ocean of OSS Softwares.. Debian


----------



## elumalai (Jun 24, 2006)

hi,

recently, my X server crashed.  And whenever, I login.., I was returend to text mode.

After that, I reinstalled the xserver by doing 
rpm -xvf force xfreei386(something....i donnow exactly).

Then, xserver started running normally.
but now a new problem starts..

now I have lost the root account (and all the user accounts)..whenever I type in the username field as 'root' it says invalid name account...caps lock...etc......*www.thinkdigit.com/forum/images/icons/icon8.gif

pls help..I already searched the net and found nothing.
I posted a thread here..no one responded..
Please help my dear friend..
thanks a lot.


----------



## Satissh S (Jun 24, 2006)

hmm..

Easy Way:- 
there is a trick for resetting root password,  
just pop in fc rescue cd and boot to rescue mode and execute the following command
$ chroot /mnt/sysimage
now ull be logged in the shell, type
$ passwd
ENTER NEW UNIX Password: <type_da_new_password>
RE-ENTER NEW UNIX Password: <type_the_new_password>
now u can activate the root acct.

DISCLAIMER: Iam not sure of the procedure as apparently i've not been to Fc or its rescue mode recently. 

HARD Way but sure-shot solution:-
Use a live cd, such as ubuntu or lfs livecd to boot ur system.
Mount your system partitions in order using commands, 

```
mkdir /mnt/hd
export new=/mnt/hd
mount -t <fs_name[1]> /dev/hdx_modify[2] $new
```
repeat the above for the different partitions u have,
use swapon to enable your swap partition

```
swapon /dev/hdx_modify[2]
```
mount the /proc partition, after mounting the root partition!!

```
mount -t proc none $new/proc
```
now use chroot to enter your new partition as root user

```
chroot $new /bin/sh
```
now execute,

```
passwd
```
Exit the chroot environment by,

```
exit
```
this changes your root password.
now unmount everything, using

```
unmount $new/proc
unmount $new/modify[3]
swapoff /dev/hdx_modify[2]
```
repeat for all partitions

```
cd /
unmount $new
```
reboot, root password should work.
---------------------------------
[1] fs_name refers to the filesystem of your partition, replace it with ext2, ext3 or reiserfs or leave it to automatically detect, simply by ordinary mounting.

```
mount /dev/hdx_modify[2] $new
```

[2] hdx_modify refers to your filesystems, replace with /dev/hda1 , /dev/hda2 , /dev/hda3 , /dev/hda4(/hda5,hda6..) as required.

[3] $new/modify refers to the partitions you mounted within the root system, like boot etc. Give accordingly.

If u feel uncomfortable, ask help from a lug,  they will help surely.


----------



## elumalai (Jun 25, 2006)

Thank you very much satissh...I will try your idea..think it shud work..

but, what is the problem is ..I know the root password...the login screen tells whenever I type 'root' and press 'enter', it says invalid user, not even asking for password (for all the user accounts too).  I use Red Hat 9.

thank you.. I wud see whether ur solution works....lets see...


----------



## Satissh S (Jun 25, 2006)

Iam unable to get u'r problem, it says user root not found??
maybe some problem in /etc/passwd or probably ur system is screwed up. 
Again enter that chroot mode and backup ur data and install a newer distro. RH9 is old, but not gold 
Thats all i have to say abt this weird problem


----------



## Satissh S (Jun 25, 2006)

check if the file /etc/passwd contains the line,

```
root:x:0:0:root:/root:/bin/bash
```
else add it by editing within the chroot environment. 
Weird, I seriously havent encountered this before


----------



## elumalai (Jun 27, 2006)

hi sattish,

sure..100% its a weird one..

thank u very much for the ideas.  I tried it but failed...
at last, I've decided to reinstall the software ( iam not goin to use redhat 9).

suggest me some good linux flavour.
my system config. is very low.
celeron 850mhz, 128mbram.


----------



## Satissh S (Jun 27, 2006)

Use slackware, it is a great distro for those hardware platforms where processing power and system memory aren't great. It can be a little trying if u'r completely new to linux, but setting up takes 25 mins approx and configuring takes some 15 mins.

Website : *slackware.com/ 
Slackbook : *slackbook.org/

As an aside, you may want to try Zipslack, a slackware variant that can fit into a zip disk. slackware is a _very_ stable distro, i suggest u use Xfce desktop Environment, which is low on resources. Enjoy Slacking.


----------



## elumalai (Jun 30, 2006)

k..slackware?? i'm not aware of that..
is it having the GUI as in windows xp or red hat or any other linux flavours.

my friend told only due to h/w limitations my linux keeps on giving probs...
i think i have to try previous versions of red hat.


----------



## Satissh S (Jul 1, 2006)

umm..hardware??
could you elaborate a bit on your hardware please?? If possible run a knoppix live-cd and give me the out put of the following 
i.e post the following file log.txt, here
# lspci > log.txt
# lsmod >> log.txt
# lsusb >> log.txt
please do the above and if possible give your full hardware configuration.


----------

