Vincent Zoonekynd's Blog

Sat, 01 Jun 2013: Gentoo

After ditching Mandriva because my machine was becoming slower and slower (instead of faster and faster), after experiencing serious latency problems while trying to watch videos on Suse, after straining my eyes on Ubuntu (I do not remember if it was because of the fonts or because I was desperately looking for a useable application), I finally turn to Gentoo.

It is a very different breed of distribution: everything is compiled from source, so that you install only the applications you need and you can fine-tune the compile flags for them (distributions on CDs are often compiled with -Os so as to minimize disk space -- this might not be what you want). It also gets rid of the patent-related problems.

That sounds very appealing, but be warned: should you decide to install this distribution, you must have several days in front of you, you must not be afraid of the command line, you must not be bewildered when you are told that the system is "finally installed" even though there is no media player, no web browser, no KDE, no Gnome, no word processor, no X -- yet.

Installing Gentoo

If you want to install Gentoo, you might be better off with the more complete official documentation.

Burn the CD, boot it.

Press ALT-F1 when prompted and select the keyboard (uk, for me).

Check that the network works (in my case, DHCP -- with you are using Wifi, replace ifconfig by iwconfig).

ping -c 1


Partition the disk.


The main commands are

m  Menu
p  List the partitions
d  Delete a partition
n  Create a new partition
t  Set the partition type ("Linux" is the default, "Linux swap" is 82)
w  Write the partition table to disk

My partitions are:

/dev/hda1  ext3   32MB  /boot
/dev/hda2  swap  1.5GB 
/dev/hda3  ext3   15GB  /
/dev/hda4  ext3   14GB  /home

Format the partitions (i.e., put an empty file system on all of them)

mk2fs -j /dev/hda1       # mk2fs creates an ext2 file system
mk2fs -j /dev/hda3       # The -j options adds a journal -- the
mk2fs -j /dev/hda4       # resulting file system is called ext3.
mkswap /dev/hda2

Create the mounting points

mkdir /mnt/gentoo
mkdir /mnt/gentoo/boot
mkdir /mnt/gentoo/home

Mount those partitions

swapon /dev/hda2
mount /dev/hda3 /mnt/gentoo
mount /dev/hda1 /mnt/gentoo/boot
mount /dev/hda4 /mnt/gentoo/home

Download what is needed

Install the "stage":

cd /mnt/gentoo
tar jxvfp /mnt/cdrom/stages/*

Retrieve the latest portage snapshot:


and unpack it (LONG)

tar jxvf portage*.tar.bz2 -C /mnt/gentoo/usr


Edit the flags in /mnt/gentoo/etc/make.conf

less /mnt/gentoo/etc/make.conf.example
vi /mnt/gentoo/etc/make.conf

In particular, the CFLAGS (-march creates binaries for this processor, without preserving backward compatibility, as -mcpu does; -O2 optimizes the code for speed -- the default, -Os, optimizes for size)


and parallel compilation


Also add the URLs of the mirrors

mirrorselect -i    -o >> /mnt/gentoo/etc/make.conf
mirrorselect -i -r -o >> /mnt/gentoo/etc/make.conf
tail /mnt/gentoo/etc/make.conf

In the chroot

Up to now, we were using the system from the CD, and we have copied a minimal system onto the hard drive; we are now ready to use that system and configure it further. (If you need to access the system on the CD, you can use another console by typing ALT-F2.)

cp -L /etc/resolv.conf /mnt.gentoo/etc/
mount -t proc none /mnt/gentoo/proc
chroot /mnt/gentoo /bin/bash
source /etc/profile

Update your system:

emerge --sync

Set you USE flags

ls -l -FGg /etc/make.profile
less /usr/portage/profils/use.desc
vi /etc/make.conf

I currently have

USE="-gtk -gnome kde qt hal -artsd -acpi dvd alsa cdr examples doc ieee1394"

Set up the time zone

cp /usr/share/zoneinfo/GB /etc/localtime


emerge vim

Compiling the kernel

Retrieve the kernel source

USE="-doc" emerge gentoo-sources
cd /usr/src
ls -l

And compile it

emerge genkernel
zcat /proc/config.gz > /usr/share/genkernel/x86/kernel-config-2.6
genkernel all
ls -l /boot/kernel*
ls -l /boot/initramfs*
emerge coldplug
rc-update add coldplug boot

You might prefer to compile it yourself (I would advise against it if it is the first time you install Gentoo and if you have not compiled a kernel for a few years: you would tend to remove everything that is apparently not needed and could end up without a network card -- and even without a keyboard...).

cd /usr/src/linux
make menuconfig
make modules_install
cp arch/i386/boot/bzImage /boot/kernel-2.6.14-gentoo-r5
cp .config /boot/config
find /lib/modules -name "*o"

File systems

Edit the file system table.

vi /etc/fstab

I have

# <fs>			<mountpoint>	<type>		<opts>		<dump/pass>
/dev/hda1		/boot		ext3		noauto,noatime	1 2
/dev/hda3		/		ext3		noatime		0 1
/dev/hda2		none		swap		sw		0 0
/dev/hda4		/home		ext3		noatime		0 0
/dev/cdroms/cdrom0	/mnt/cdrom	iso9660		noauto,ro	0 0

proc			/proc		proc		defaults	0 0
shm			/dev/shm	tmpfs		nodev,nosuid,noexec	0 0

Set-up the hostname and domain name

vi /etc/conf.d/hostname                # gentoo
vi /etc/conf.d/                        # DNSDOMAIN=home
rc-update add domainname default
rc-update add net.eth0 default
vi /etc/hosts

Set up the super-user password.


Check from where it can login.

less /etc/securetty


vi /etc/rc.conf              # EDITOR=/usr/bin/vim


vi /etc/conf.d/keymaps       # "uk" instead of "us"

System utilities

A logging utility.

emerge syslog-ng
rc-update add syslog-ng default

A crontab utility, to allow you to run commands at specified times.

emerge vixie-cron
rc-update add vixie-cron default

The "locate" command, that keeps an easy-to-search list of all the files on the disk. It will be updated every night (the first time, you can populate that list of files by issuing the "updatedb" command).

emerge slocate

The DHCP client, in order to be connected to the internet.

emerge dhcpcd      # Do not forget the "c" ("client") before the "d"

Boot loader

emerge grub
vi /boot/grub/grub.conf

I have:

timeout 30
default 0

title  GNU/Linux 2.6.14-gentoo-r5
root (hd0,0)
kernel /boot/kernel-genkernel-x86-2.6.14-gentoo-r5 vga=791 splash=silent root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/hda3 udev
initrd /boot/initramfs-genkernel-x86-2.6.14-gentoo-r5

Install the bootloader:

grep -v rootfs /prov/mounts > /etc/mtabs    # Missing in the chroot environment
grubinstall /dev/hda


exit      # You cannot reboot in the chroot
          # Alternatively, you could use another console (ALT-F2)


If it does not reboot properly (e.g., because you said "gb" instead of "uk" for the keyboard and end up with no keayboard, or because you chose to compile the kernel yourself and inadvertently remove the support for the keyboard, the network or both), boot from the CD, mount the file systems, chroot to the hard drive and work from there.

swapon /dev/hda2
mount /dev/hda3 /mnt/gentoo
mount /dev/hda1 /mnt/gentoo/boot
mount /dev/hda4 /mnt/gentoo/home
mount -t proc none /mnt/gentoo/proc
chroot /mnt/gentoo /bin/bash
source /etc/profile

Gentoo is installed -- Is it?

New user

useradd -m -G users,wheel,audio zoonek
passwd zoonek

useradd -m -G users,audio beta

Other distributions suggest to put users in a group of their own ("zoonek"'s default group will be "zoonek"), which is probably better -- if you have many users, you are likely to put them into groups that appear fine at one time but prove troublesome later; furthermore, permissions on files are safer that way.

groupadd zoonek
useradd -m -G zoonek,users,wheel,audio zoonek

# If the user has already been created:
groupadd zoonek
gpasswd -a zoonek zoonek

A "few" things are missing

To put it simply, everything is missing: you have a shell, almost everything you could expect to come with a shell, and that is all. No Video or MP3 player, no Office suite, no web browser, no graphical environment -- not even a text-based web browser: links2 was on the CD but it is not here.

emerge --search links2
emerge --search links
USE="-x" emerge elinks

Bad idea

My first movement was to check that everything was up-to-date and update what was to be updated.

emerge --sync
emerge --update --deep world   # If you are lucky, it might take 
                               # less than 24 hours. (I did not wait.)
		 # Do not expect to be lucky.

A graphical environment

emerge --pretend kde | less
emerge kde                     # Less than 48 hours (I did wait)

We finally have a working R environment. Well, not, it is there, but it is not running, nor even working. We need to set up the xorg.conf file.

Xorg -configure   # Automatic
X -config /root/
xorgcfg           # Semi-automatic
xorgcfg -textmode
(X & ); sleep 60; killall Xorg
vi /etc/X11/xorg.conf    # My screen resolution is 1280*1024
                         # My mouse is in /dev/input/mouse1

echo "exec startkde" > ~/.xinitrc

vi /etc/rc.vonf            # DISPLAYMANAGER=kdm
rc-update add xdm default

When/if it is running, check that the resolution is the right -- if you get unreadable fonts, this is the most probable cause: check that the resolution is indeed the one you specified, check in the monitor manual what the actual resolution is.


KDE: removable devices

# Automatically mounting new devices when they are plugged
emerge --no-replace dbug hal
rc-update add dbus default
rc-update add hald default
gpasswd -a zoonek plugdev
gpasswd -a beta   plugdev
emerge ivman
rc-update add ivman default

I am not sure it works. If it does not, mount and unmount the devices by hand.

mount /mnt/cdrom /dev/cdrom
umount /mnt/cdrom

If you do not know the device name (e.g., USB keys), try

file -s /dev/sd*

or things like

udevinfo -a -p /sys/block/sda | grep vendor


P2P applications usually take up a lot of ressources (think "Azureus" -- which is not that bad, actually: it will only take up 40% of your CPU -- for a non-CPU-bound task), mainly because of their GUI. MLDonkey is just a server, with almost nothing on top of it, so its load on the system is minimal. (In case you wonder, yes, "ML" refers to functional programming -- it is a CaML program).

emerge net-p2p/mldonkey
rc-update add mldonkey default
/etc/init.d mldonkey start

You can then telnet to port 4000 or point your web browser to http://localhost:4080/ (only accessible from the local machine). It knows about most P2P networks, in particular BitTorrent.

The files are saved in /home/p2p/mldonkey/incoming/*/.


There is no telnet command...

emerge telnet-bsd

External hard drive

It was initially designed for a machintosh but I had somehow managed to remove the HFS partition and replace it by two ext3 ones. Unfortunately, I only did half the job: these are Linux partitions, but the partition table is still a Macintosh one...

gentoo ~ # dmesg
ieee1394: The root node is not cycle master capable; selecting a new root node
and resetting...
ieee1394: Node added: ID:BUS[0-00:1023]  GUID[00d04b590e076011]
ieee1394: Node changed: 0-00:1023 -> 0-01:1023
scsi0 : SCSI emulation for IEEE-1394 SBP-2 Devices
ieee1394: sbp2: Logged into SBP-2 device
ieee1394: Node 0-00:1023: Max speed [S400] - Max payload [2048]
  Vendor: Maxtor 6  Model: L300R0            Rev: BAH4
    Type:   Direct-Access-RBC                  ANSI SCSI revision: 04
    SCSI device sda: 586114704 512-byte hdwr sectors (300091 MB)
    sda: asking for cache data failed
    sda: assuming drive cache: write through
    SCSI device sda: 586114704 512-byte hdwr sectors (300091 MB)
    sda: asking for cache data failed
    sda: assuming drive cache: write through
     sda: unknown partition table
     Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
     SQUASHFS error: Can't find a SQUASHFS superblock on sda

gentoo ~ # file -s /dev/sda
/dev/sda: Apple Partition data block size: 512, 
first type:  Apple_partition_map, name: Apple,        number of blocks: 7, 
second type: Apple_Driver43,      name: Macintosh_SL, number of blocks: 94, 
third type:  Apple_FWDriver,      name: Macintosh_SL, number of blocks: 151, 
fourth type: Apple_UNIX_SVR2,     name: Linux ext3,   number of blocks: 207024128

gentoo ~ # fdisk -l /dev/sda
Disk /dev/sda: 300.0 GB, 300090728448 bytes
255 heads, 63 sectors/track, 36483 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sda doesn't contain a valid partition table

And, of course, the kernel does not recognize those file systems...

gentoo ~ #  gzip -dc /proc/config.gz | grep HFS
# CONFIG_HFS_FS is not set
# CONFIG_HFSPLUS_FS is not set

gentoo ~ # cat /proc/filesystems
nodev   sysfs
nodev   rootfs
nodev   bdev
nodev   proc
nodev   sockfs
nodev   pipefs
nodev   futexfs
nodev   tmpfs
nodev   inotifyfs
nodev   eventpollfs
nodev   devpts
nodev   ramfs
nodev   usbfs

Since I want the data on this disk (I use it first as a backup, second to store large files), I will have to recompile the kernel...

genkernel --bootsplash --no-clean --menuconfig all

I change the following options.

# CONFIG_HFS_FS is not set
# CONFIG_HFSPLUS_FS is not set

Recompile alsa-driver, if needed (see the "Alsa" section).

emerge alsa-driver

Put the new kernel in the /boot/grub/grub.conf file and update the boot sector.

grubinstall /dev/hda

IEEE1394 woes

No, it is not finished.

When I reboot with the new kernel, the Macintosh partition table is recognized, but the network has disappeared.

The reason is the following: the network interface is usually eth0, but if the hard drive is plugged when the machine boots, the kernel sees an IEE1394 device that could possibly be used as a network interface -- it gets the name eth0 and the (real) network card becomes eth1.

The first solution is to plug the hard drive once the system has booted.

Another solution is to look for an eth1 network interface.

cd /etc/init.d/
ls -l net.*
ln -s net.lo net.eth1

A cleaner solution would be to use udev -- but that is another story.


Accessing sound devices on Linux is exceedingly complicated: you have to choose between the old OSS way and the new (but harder to configure) Alsa one -- and on top of that, there can also ba a "sound server", such as artsd, esd, gstreamer, jackd.

I think that the main difference is that Alsa contains a "mixer" and thus allows you to play several sounds at the same time. In particular, an application will be able to "beep" even if another one is playing music; or an application will be able to play music even if another one forgot to close the sound device (because it somehow crashed or opened the sound device for a beep and did not bother to close it).

[I plan to investigate sound in Linux (not "playing MP3 files" but really music or sound creation) in much more details -- but that will be another (series of) article(s) -- stay tuned.]

For more details on using and installing Alsa, see:

Check that it is not in the kernel (you can install Alsa either with the kernel or separately, but the two are mutually exclusive):

gentoo linux # gzip -dc /proc/config.gz  | egrep 'SOUND|SND'
# CONFIG_SND is not set                         # Alsa
# CONFIG_SOUND_PRIME is not set                 # OSS

Install alsa-driver (should be reinstalled whenever you recompile the kernel: it is actually a kernel module):

emerge alsa-driver
emerge alsa-utils
rc-update add alsasound boot
cat /proc/asound/cards
cat /proc/asound/version

To check that it actually works, first run "alsamixer", un-mute (by pressing (or not) the M key) all the channels, and type

cat /dev/urandom  > /dev/dsp   

This should produce white noise (remember that /dev/random produces cryptographic-quality random numbers, at a very slow speed, while /dev/urandom produces pseudo-random numbers, suitable for most applications, as fast as you want).


We can also play Midi sounds with Alsa:

emerge timidity++

# Choose one of the following soundfonts
emerge timidity-eawpatches
timidity-update -g -s eawpatches

# or
emerge timidity-shompatches
timidity-update -g -s shompatches

rc-update add timidity default
/etc/init.d/timidity start
/etc/init.d/alsasound restart   # Important!

aplaymidi -l
aplaymidi -port 0:65 foo.midi

Well, actually, it does not work.

zoonek@gentoo /tmp $ aplaymidi -l
ALSA lib seq_hw.c:455:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
Cannot open sequencer - No such file or directory

You can play a Midi file simply by

timidity foo.mid


I edit the /etc/make.conf to add the following USE flags.

USE="aac dts live xanim xvid theora win32codecs real matroska mythtv"

First build it WITH CPU detection, to see if your processor has more capabilities that could be added.

USE="cupdetection" emerge mplayer

When I run mplayer, it tells me:

CPU: Intel Pentium 4/Xeon/Celeron Foster (Family: 8, Stepping: 4)
Detected cache-line size is 64 bytes
MMX supported but disabled
MMX2 supported but disabled
SSE supported but disabled
SSE2 supported but disabled
CPUflags:  MMX: 0 MMX2: 0 3DNow: 0 3DNow2: 0 SSE: 0 SSE2: 0
Compiled with runtime CPU detection - WARNING - this is not optimal!
To get best performance, recompile MPlayer with --disable-runtime-cpudetection.

So I add some more flags:

USE="rtc mmx mmxext sse sse2" emerge mplayer

MPlayer, Gentoo and APE files

On the internet, you can find audio APE files (aka MAC: Monkey Audio Codec): this is apparently a "free" lossless audio codec. However, if you try to get the licence, you realize that the Linux version is a port of the Windows one, done without the agreement of the initial author -- he claims that his software is "free", that no one is allowed to modify the code, that he will grant anyone who asks him the right to port it to other platforms, but actually fails to answer any such request.

In short, APE is a licence-less audio codec.'s_Audio

As there is no legal licence, it is not readily available on Gentoo: I install it from source.
cd mac*/

I can now convert the APE files that still lie around on my hard drive to FLAC (another lossless audio format -- really free, this one).

mkdir RM
for i in *.ape
  echo "$i"
  mac "$i" "$i".wav -d
  flac --best "$i".wav
  rm -f "$i".wav
  mv "$i" RM/

Sometimes, it is a whole CD that has been encoded in that way: the *.ape file has to be split from the informations contained in the *.cue file.

ACCEPT_KEYWORDS=~x86 emerge cuetools
emerge shntool
cuebreakpoints foo.cue | shnsplit -o flac foo.ape

# Or:
cuebreakpoints foo.cue | shnsplit -o cust ext=mp3 \{ lame -V3 - %f \} foo.ape


emerge wavpack

Other codecs

WMA  (very low quality)
APE  (aka MAC, Monkey's Audio Codec)
FLAC (Free Looseless Audio Codec)
MPC  (Musepack)

MPlayer and h264

Video files are more complicated. They contain several "streams", e.g., video (there can be several video streams, corresponding to several cameras following the event being recorded), sound (there can be several languages) and subtitles -- with some more information such as menus, chapters, etc.

There are several container formats (Matroska (mkv), AVI, MP4, DivX, Ogm), and each of these streams can be encoded in a variety of codecs (e.g., Ogg, Mp3, AAC for the audio; MPEG-4 Advanced Simple Profile Video (DivX, Xvid), Theora, H264 (aka MPEG-4 Advanced Video Coding (AVC)) for the video).

The problem, for me, is that the most recent codecs require a fast processor -- faster than mine.

Starting playback...
[h264 @ 0x86511a0]QP -20 out of range
Error while decoding frame!
mplayer: h264.c:2306: mc_dir_part: Assertion `pic->data[0]' failed.97%

MPlayer interrupted by signal 6 in module: decode_video
- MPlayer crashed. This shouldn't happen.
  It can be a bug in the MPlayer code _or_ in your drivers _or_ in your
  gcc version. If you think it's MPlayer's fault, please read
  DOCS/HTML/en/bugreports.html and follow the instructions there. We can't
  and won't help unless you provide this information when reporting a
  possible bug.

It works more or less fine with vlc, but I am really reaching the limits of the processor (it uses 100% of the CPU and fast action scenes produce an error message as above).

One solution might be to convert the file to another video format. Here is what I tried, following the instructions from

ACCEPT_KEYWORDS=~x86 emerge media-video/gpac     # For MP4Box (Masked by ~86)
emerge media-libs/faad2                          # For faad, to convert AAC to WAV
emerge media-video/ffmpeg

MP4Box -raw 1 a.mp4   # Creates a_track1.h264
MP4Box -raw 2 a.mp4   # Creates a_track2.aac
faad a_track2.aac     # Creates a_track2.wav
# Creates a sound-less a_noaudio.avi file
ffmpeg -i a_track1.h264 -vcodec xvid -vtag xvid -b 1000 -an a_noaudio.avi
# Creates the final a.avi file, with sound
ffmpeg -i a_noaudio.avi -vcodec copy -vtag xvid -i a_track2.wav -acodec mp3 a.avi

But it still does not work: the file is huge, the quality of the image is awful (the initial file was abnormally small and the image crystal-clear) and the sound is not in sync with the video...

I give up: I will shelve those files until I buy a new computer...


You can install it as usual (there is also a "blas" USE flag, but it does not work).

USE="tcltk" emerge --pretend --verbose R

This will probably not be the latest version: to get it, try the ~x86 one

USE=tcltk ACCEPT_KEYWORDS=~x86 emerge R

or compile it from source, as usual.

emerge tk
emerge app-admin/sudo    # Used by JGR
man sudo
man sudoers
visudo   # Uncomment the "%wheel ALL=(ALL) ALL" line

./configure --enable-R-shlib 
make install

wget -r -l 1 -np -nc -x -k -K -E -U Mozilla 
for i in*.tar.gz

tar zxvf JGR*.tar.gz
cd JGR*/
perl -p -i -e 's#^JAVAHOME=.*#JAVAHOME=/opt/blackdown-jdk-' Makefile.linux

Crontab (alarm clock)

As root:

gpasswd -a zoonek cron

As me:

crontab -e

The crontab now contains

zoonek@gentoo ~ $ crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXXvEPxwU installed on Mon Jan  2 23:41:17 2006)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
55 6 * * * /home/zoonek/bin/

Where is

mplayer -cache 64 mms://
mplayer -cache 64 mms://
mplayer -cache 64 mms://
mplayer -cache 64 mms://
mplayer -cache 64 mms://

(It can be stopped by typing "killall mplayer" five times.)


To avoid popups, type "about:config" in the address bar and set "browser.tabs.opentabfor.windowopen" to true. The popups, if any, will appear in a new tab in stead of a new window.


emerge gqview
emerge gimp
emerge blender
emerge zsh
emerge scribus
emerge cdrtools cdrdao dvd+rw-tools     # mkisofs, cdrecord
emerge nmap netcat
USE="gtk" emerge ethereal
emerge openoffice                 # 15 hours? More?
emerge unace lha
emerge tetex
emerge imagemagick

emerge ecasound
# For other sound-producing tools, check:
#   /var/cache/edb/dep/usr/portage/media-sound/
# I might soon try:
#   amsynth ardour audacity beast cheesetracker fluidsynth
#   hydrogen jamin jmax lilypond muse pd qjackctl qsynth rezound rosegarden
#   soundtracker spiralmodular supercollider zynaddsubfx

# With or without Java??? 
# (Java is needed, among others, for the database component, HSQLDB (a DBMS
# completely written in Java).
USE="java" emerge openoffice      # 15 hours? More?

ACCEPT_KEYWORDS=~x86 emerge --pretend --verbose f-spot     # Requires Mono (C#)

emerge --one-shot amsynth ardour audacity beast cheesetracker fluidsynth
hydrogen jamin jmax lilypond muse pd qjackctl qsynth rezound rosegarden
soundtracker spiralmodular supercollider zynaddsubfx


By default, there are no japanese fonts.

# In the /etc/make.conf file:
USE="cjk nls unicode immqt"

emerge media-fonts/kochi-substitute   # Japanese
emerge media-fonts/arphicfonts        # Chinese
emerge media-fonts/baekmuk-fonts      # Korean

locale -a | grep -i utf
echo LANG="en_GN.UTF-8" >> /etc/env.d/02locale
source /etc/profile 

emerge anthy scim-uim skim

cat >> ~/.xprofile     # or /etc/xprofile
export GTK_IM_MODULE=scim
export QT_IM_MODULE=scim 

For more information:


I always have font-related problems -- I do not find them readable. From that point of view, Gentoo is not as bad as some distributions, but there is room for improvement: some fonts, though prefectly legible, are ugly and/or at the wrong resolution.



I follow the instructions from

euse --enable bitmap-fonts truetype-fonts type1-fonts
emerge --newuse --noreplace freetype corefonts freefonts artwiz-fonts \
      sharefonts terminus-font ttf-bitstream-vera unifont dejavu xorg-x11
USE=-bindist emerge --newuse freetype  # Already there, actually

Edit /etc/fonts/local/conf to enable sub-pixel rendering (if you are using an LCD screen).

# With sub-pixel rendering:
# Without:

Edit /etc/X11/xorg.conf

Section "Monitor"
  DisplaySize         340 270   # 1280*1024, 96 dpi

In the same file, add the fonts (this assumes we are not using a font server):

Section "Files"
  FontPath   "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"
  FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"
  FontPath   "/usr/X11R6/lib/X11/fonts/TTF/"
  FontPath   "/usr/X11R6/lib/X11/fonts/Type1/"
  FontPath   "/usr/share/fonts/corefonts"
  FontPath   "/usr/share/fonts/freefont"
  FontPath   "/usr/share/fonts/sharefonts"
  FontPath   "/usr/share/fonts/artwiz"
  FontPath   "/usr/share/fonts/terminus"
  FontPath   "/usr/share/fonts/ttf-bitstream-vera"
  FontPath   "/usr/share/fonts/unifont"

  # Everything in /usr/share/fonts/
 #   find /usr/share/fonts/ -type d | perl -p -e 's/(.*)/FontPath "$1"/'
  FontPath "/usr/share/fonts/local"
  FontPath "/usr/share/fonts/util"
  FontPath "/usr/share/fonts/misc"
  FontPath "/usr/share/fonts/cyrillic"
  FontPath "/usr/share/fonts/ukr"
  FontPath "/usr/share/fonts/kochi-substitute"
  FontPath "/usr/share/fonts/arphicfonts"
  FontPath "/usr/share/fonts/baekmuk-fonts"
  FontPath "/usr/share/fonts/CID"
  FontPath "/usr/share/fonts/ttf-bitstream-vera"
  FontPath "/usr/share/fonts/corefonts"
  FontPath "/usr/share/fonts/freefont"
  FontPath "/usr/share/fonts/artwiz"
  FontPath "/usr/share/fonts/sharefonts"
  FontPath "/usr/share/fonts/terminus"
  FontPath "/usr/share/fonts/unifont"
  FontPath "/usr/share/fonts/dejavu"
  FontPath "/usr/share/fonts/75dpi"
  FontPath "/usr/share/fonts/100dpi"


My /var/lib/portage/world file (it is created automatically, with all the software you install via "emerge"; if you want to install a piece of software without seeing it here, install it with the --one-shot option).


My /etc/portage/package.keywords file (you have to create it yourself)

media-video/gpac ~x86
media-gfx/f-spot ~x86

For the second one, it is actually much trickier: this only tells to accept the unstable versino of F-spot, but F-spot depends on a wealth of other packages that do not have a stable version (e.g., Mono...).

media-video/gpac ~x86

dev-dotnet/glade-sharp ~x86
dev-dotnet/gconf-sharp ~x86
dev-dotnet/art-sharp ~x86
dev-dotnet/gnomevfs-sharp ~x86
dev-dotnet/gnome-sharp ~x86
dev-dotnet/libgdiplus ~x86
dev-dotnet/gtkhtml-sharp ~x86
dev-dotnet/gtk-sharp ~x86
dev-lang/mono ~x86
media-gfx/f-spot ~x86

My /etc/portage/packages.use:

net-analyzer/ethereal gtk

Learning about the system


Information about non-installed programs:

emerge --info                     # Global USE flags
emerge --pretend foo              # Dependencies of "foo"
emerge --pretend --verbose foo    # USE flags for package "foo

Looking for a package:

emerge --search foo
emerge --searchdesc foo
equery files foo                  # Contents of (installed) package foo
equery belongs foo                # (Installed) packages containing file "foo"

Removing programs and cleaning the system:

emerge --unmerge foo              # Removes "foo" but leaves its dependencies
emerge --depclean                 # Also removes the dependencies (removes
                                  # everything that is not needed by what is 
		    # listed in the world file)
emerge -p --depclean              # Lists what would be removed (orphaned packages)
revdep-rebuild                    # To be run after emerge --depclean

Updating the system:

emerge --update --deep --newuse world      # Recompile what should be recompiled
etc-update                                 # Updates the configuration files in /etc/
emerge --help config                       # Details of etc-update's action

To install Perl modules:

emerge g-cpan
man g-cpan
g-cpan -i XML::Parser::PerlSAX
g-cpan -i File::Cat
g-cpan -i MIME::Types
g-cpan --install WWW::Mechanize

USE flags (in /etc/make.conf)

Programs can be compiles with or without some capabilities, or optional dependancies: they are described in the USE variable -- it can come from the /etc/make.conf file, from the /etc/portage/package.use file (on a package-by-package basis) or from the environment. Here is the one I use.

USE="-gtk -gnome -acpi qt kde hal -artsd dvd alsa cdr examples doc ieee1394

   aac dts live xanim xvid theora win32codecs real flac matroska mythtv 
   rtc mmx mmxext sse sse2 cjk immqt-bc unicode"


The programs that are run when the machine boots (or when it shut down) are in /etc/init.d/. More precisely, this directory contains all those programs, wether they are scheduled to be run or not. Those that are actualy run are in /etc/runlevels/default/* (this directory differs from one distribution to the next): these are symbolic links to /etc/init.d/.

These are all shell scripts that accept an argument: start, restart, stop, status.

The rc-update command tells you what is actually run and allows you to add or delete programs.

rc-update add net.eth0 default
rc-update show


This command tells you what daemons have been started in the current runlevel (those scheduled with rc-update) and wether they are still running or not.


/etc/conf.d/local.start      # Personal stuf to be run at startup
/etc/conf.f/local.stop       # ... to be stopped before shutdown


/etc/conf.d/keymaps          # Which keyboard (us, uk, fr, etc.) do you have?

/etc/conf.d/gpm              # Configuration of GPM, a utility to use the
                             # mouse in the console


Classically, the devices (that means anything that can get plugged into the computer: mouse, hard drive, terminals, USB keys, etc.) are assigned unpredictable names in /dev/.

Some are predictable: the (IDE) hard drives will be called /dev/hda, /dev/hdb, /dev/hdc and /dev/hdd; their partitions will be called /dev/hda1, /dev/hda2, etc. -- the rules are actually more complicated than it may seem, but it is predictable.

Some device names are not predictable: if you plug in a USB key, then unplug it, the replug it, it will not have the same name.

Udev solves that problem and allows you to specify the name a device gets when it is plugged. In particular, you can then assign it a fixed mount point in /dev/fstab.

To define the names you want, create a /etc/udev/rules.d/10-local.rules along the lines of /etc/udev/rules.d/50-udev.rules.

Your own rules could look like this:

BUS="usb", SYSFS{serial}="HXOLL0012202323480", NAME="lp_epson", SYMLINK="printers/epson_stylus"

# Or, if we wish to retain the initial kernel name:
BUS="usb", SYSFS{serial}="HXOLL0012202323480", NAME="%k", SYMLINK="lp_epson printers/epson_stylus"

# We use the kernel name so as to distinguish between sda and sda1
# (with several partitions, we could also use the size)
BUS="scsi", SYSFS{model}="L300R0", KERNEL="sd*1", NAME="%k", SYMLINK="Hard_Drive_300G"

# If we want all the partitions:
BUS="scsi", SYSFS{model}="L300R0", KERNEL="sd*", NAME="%k", SYMLINK="Hard_Drive_300G%n"

To get that information:

udevinfo -q path -n /dev/sda
udevinfo -a -p /sys`udevinfo -q path -n /dev/sda`
udevinfo -a -p /sys/block/sda
udevinfo -a -p /sys/bus/scsi/devices/3:0:0:0

For more details:

Sysadmin toolbox

chroot               # Also check jail (BSD), VServer, UML
nmap                 # Network probing: check what ports are open on a
                     # remote machine.
netstat -n           # Displays open ports
netstat -nr          # Route table
netstat -ni          # Network interface
lsof                 # List of open files
lsof -n | grep tcp   
vmstat 5
iostat               # Where is it???
netcat -l -p 1234 > filename                 # Listen to a port
cat filename | netcat hostname 1234 -q 10    # Send a file to a remote port,
                                             # wait 10 seconds before quitting
dig                  # Talk to the DNS
ethereal             # Network capture
                     # Be sure to install it with the "gtk" USE flag,
       # otherwise you only get the text-based version.
screen               # A kind of VNC for console

amanda, mondo rescue, sbackup    # Backup utilities
unisson, rsync
nagios, mrtg, bb     # Monitoring tools, if there are several machines 
                     # on your network -- useless for me
pwgen                # Password generator
xte "mousemouve 1024 768"  # To automate the interaction with a 
                           # graphical program from the command line
                           # Install with: emerge xautomation


Web browser:                  Firefox (see also Konqueror -- use wget to
                              download whole sites from the command line)
EMail:                        KMail
RSS reader:                   Akregator
Office suite:                 OpenOffice.Org
Word processor:               LaTeX
Image viewer:                 gqview (see also gwenview, gthumb, qiv, zvg)
Image editor (bitmap):        The Gimp
Drawing (vector graphics):    Inkscape
3D:                           Blender (see also povray)
Media player:                 mplayer (yes, I know, there is no GUI -- if
                              you really need a GUI, check Amarok as a 
                              music player and... well, I do not have
                              anything with a GUI to play videos)
                              (see also bmpx)
Games:                        Frozen Bubble (check also Nexuiz, etc.)
Text editor:                  Vim, Emacs, XEmacs, see also Kate
Programming languages:        C, C++, Perl, Python, Ruby, CaML, Php
Statistics:                   R
Numerical computations:       Scilab
Formal computations:          Maxima
Audio editor:                 Audacity (see also Ardour, more professionnal)

For more, see

posted at: 19:17 | path: /Linux | permanent link to this entry