Menu

QUICK-N-DIRTY GUIDE TO USING OPENSSH KEYPAIR AUTHENTICATION

To generate a keypair, run:

ssh-keygen -t dsa

(you are advised not to protect the key with a password, as you will then be
prompted for the password everytime you connect). The keypair will be saved
(by default) in $HOME/.ssh/id_dsa, and $HOME/.ssh/id_dsa.pub (the .pub file
is the public key, and the other is the corresponding private key). Now, set
the permissions to protect your $HOME/.ssh/ directory. (Note that these modes
are the most lax permissions that these files and directories are allowed to 
have. You may certainly set the permissions stricter.)

chmod 711 $HOME/
chmod 700 $HOME/.ssh/
chmod 644 $HOME/.ssh/*
chmod 600 $HOME/.ssh/id_dsa

Finally, add the public key to the $HOME/.ssh/authorized_keys file on each
machine to which you wish to connect and set the correct permissions. (Note
that you will be prompted for a password with each command. An alternative is
to login to server and run the commands locally. If you do so, remove the
quoting from the rightmost arguments.)

cat $HOME/.ssh/id_dsa.pub server 'cat >>.ssh/authorized_keys'
ssh server chmod 711 "$HOME/"
ssh server chmod 700 "$HOME/.ssh"
ssh server chmod 644 "$HOME/.ssh/authorized_keys"

For each machine you want to be able to connect from, first copy the id_dsa
file (the private key) to that machine, then follow the above steps.

The Quick-N-Dirty Guide to ssmtp

The aim of this QND guide is to get you up and running quickly with ssmtp. There will be far more how than why here.

The ssmtp program is designed to be a substitute for sendmail (or postfix, exim and other heavy duty MTA’s) for people who need an external smtp program to send mail, such as those who use mutt. While it is slightly more complex and heavy than nbsmtp (no brainer smtp) it is a bit more efficient, writes to /var/log/maillog and has a few nice features.

1.) Do you have ssmtp?

I don’t know of any Linux distro or other *nix system that installs ssmtp by default. However, it never hurts to check. At a command line type

which ssmtp

If you get a response like /usr/bin/ssmtp or /usr/local/sbin/ssmtp, you can skip to step 3. Otherwise, continue with step 2.

2.)Installing

First follow the instructions in the QND software guide for information on getting and installing ssmtp. If it’s not included with your distribution (while it is in Gentoo’s portage and FreeBSD’s ports, it doesn’t seem to be on any of the RedHat 8.0 CD’s) then go to the homepage. They have a tar.gz file.

3.)Installing ssmtp

FreeBSD’s ports or Gentoo’s portage will install ssmtp for you. If you’ve downloaded the tarball then untar it somewhere and install it in the more or less usual way. This will have to be done as root or with root privilege.

tar -zxvf ssmtp*tar.gz
cd ssmtp*
./configure
make
make install

4.)Configuring ssmtp

The ssmtp program will install either a sample conf file or the actual file in /usr/etc or perhaps /usr/local/etc, depending upon distribution. This file will have to be edited slightly to make it work. Some of the comments in the file can be a bit misleading. I am including an entire file from a FreeBSD installation, with the hope that it will be clearer where you have to make changes. I am typing in ALLCAPS above the lines that you will have to change.

#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#

# The person who gets all mail for userids < 1000
root=postmaster

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.

CHANGE THE LINE BELOW


mailhub=mail

# Example for SMTP port number 2525
# mailhub=mail.your.domain:2525
# Example for SMTP port number 25 (Standard/RFC)
# mailhub=mail.your.domain        
# Example for SSL encrypted connection
# mailhub=mail.your.domain:465

# Where will the mail seem to come from?

THIS LINE WILL HAVE TO BE EDITED


rewriteDomain=

# The full hostname


THE BELOW LINE WILL HAVE TO BE CHANGED


hostname=

# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.


THE LINE BELOW SHOULD BE UNCOMMENTED 

#FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.
#UseTLS=YES

# Use SSL/TLS certificate to authenticate against smtp host.
#UseTLSCert=YES

# Use this RSA certificate.
#TLSCert=/usr/local/etc/ssmtp/ssmtp.pem

For our example, we’ll assume that your isp is called isp.com and their smtp server is smtp.isp.com. The local hostname is john.john.com The first line to be changed is the one marked mailhub=mail In our case, with an smtp server called smtp.isp.com it should be changed to read

mailhub=smtp.isp.com

Next, we cover the line that reads rewriteDomain=
Using our example of having an isp called isp.com it should be changed to read

rewriteDomain=isp.com

In other words, the domain of your isp, eg mindspring.com or whatever. Next, the hostname. The line that reads hostname should be changed to the local hostname.

hostname=john.john.com

The last change to be made is in the line that says FromLineOverride=YES. Many people, (judging from google) including myself, found that line a bit confusing. If you don’t uncomment it (by removing the # sign) you may find that all your mail comes from User &. So, uncomment it.

5.) Testing ssmtp

To test ssmtp, try sending an email. You can send one to yourself, and make sure you get it, or elsewhere. You can also look at /var/log/maillog which should show that the mail was sent successfully.

References

man ssmtp

The Quick-N-Dirty Guide to Screen

Screen is a useful application. We’re only going to cover two of its more common uses in this article.

1.) Do you have screen

At a command prompt type

which screen

If you get an answer like /usr/bin/screen or /usr/local/bin/screen go to step three, otherwise go to step two.

2.) Installing screen

See our installation guide for instructions on installing screen in your distribution. It’s a well-known application so almost all distributions have their own version of it.

3.) Using screen

Screen has several uses. My most frequent use of it is when I’m working on something either in X, console or remotely, and may want to change from one to another.

For example, while at home, I log into a server at work. I have something that might take time on the server, but my connection between home and work is problematic. So, I get on through our company’s VPN and log into the server.

Now, I have to copy a very large directory which may take 20 minutes. If my connection gets cut off during that twenty minutes, something may go wrong. However, if I use screen

screen cp SP02 SP02.bak

I can now detach the screen. The default key combination to preface any command to screen is ctrl+A (which will be abbreviated as C-a). So

C-a
d

This will detach the screen. I can now log off. Ten minutes later, I wish to check on its progress so once again I connect and

screen -r

The d and r stand for detach and reattach. If the process is finished, I will get a message that there is no screen to be resumed. Otherwise, it will put me back where I was when I detached the screen.

Another handy use of screen is to make two windows in a console. To do this

C-a
Shift+S

This creates a second window. The cursor is still in the top window

C-a
tab
C-a
c

One tabs to the second window, then does the C-a combination again and c. You will then be able to enter a command. This is far less cumbersome to do than it may seem from reading it.

References
man screen

The Quick-N-Dirty Guide to Inputting Japanese in Linux, FreeBSD and NetBSD

The aim of this QND guide is to get you up and running quickly and being able to input Japanese in Linux, FreeBSD and NetBSD. There will be far more how than why here.

1.) Do you have the Necessary Tools?

You will need a few items for this to work. They are canna, kinput2 and a terminal capable of displaying Japanese. I use rxvt, there is another one called mlterm. If your distribution has these packages available, that makes it easier. FreeBSD, NetBSD, Gentoo Linux and Fedora, nee RedHat, among others all have these available. Most other distributions do have rxvt and mlterm. (If you are using ArchLinux, use rxvt_ja from unofficial).

If you are unsure how to find these programs in your distribution, take a quick look at our software guide for information about getting and installing the items.

If you are running Slackware, Arch, Yoper, Crux or several others, you might find our vanilla kinput-canna tarball useful. Download it here take a quick look at our guide on installing from source then read on to step two, where we give a bit more information.

To see if you do have these programs at a command prompt type

which kinput2
which cannaserver
which rxvt
which mlterm

2.) Installing the Necessary Tools

If these packages were included with your distribution, then hopefully you’ve installed them. If you have to use our vanilla tarball, then do the following to install canna and kinput2.

tar -jxvf vanillajpn.tar.bz2
tar -zxvf Canna*
tar -zxvf kinput
cd Canna36p1
xmkmf
make Makefile
make canna
make install
make install.man

Next, kinput2.
Do a cd back to the directory in which you untarred it and then

cd kinput2-v3.1-beta3
xmkmf
make Makefile
make depend
make 
make install

In most cases, you will want cannaserver to start upon bootup. This varies with each distribution, so hopefully you know how to do it with yours. If not, check out our QND guide about running a program upon boot and see if your distribution is mentioned there.

3.) Configuring the Necessary Tools

I am assuming that you want your menus and such to be in English. Create a shell script. I usually put it in /usr/local/bin, but you can put it anywhere in your $PATH, including your ~/bin directory. For Linux it might work if you just put

#!/bin/bash
XMODIFIERS="@im=kinput2"  LC_CTYPE=ja_JP ${1+"$@"} &

If your browser broke that, it should be two lines, the first one being the #!/bin/bash and everything else on the second line. For FreeBSD 5.x and NetBSD

#!/bin/sh
XMODIFIERS='@im=kinput2' LANG=ja_JP.eucJP ${1+"$@"} &

The ja_JP.eucJP might, in different distributions, have to be EUCJP, EUC-JP or other variants. Usually you can determine which it should be by doing

locale -a | grep ja_JP

For example in FreeBSD I get

ja_JP.SJIS
ja_JP.UTF-8
ja_JP.eucJP

Therefore, I use eucJP rather than EUCJP.
Add the following to your .xinitrc (although in RedHat use .Xclients or .Xclients-default).

kinput2 -canna &

4.) Test the Necessary Tools

Fire up X. Open up an rxvt or mlterm terminal. Try calling a program with the langx script, for example

langx vi

Now, hit shift+space. You should see a hiragana a. (ยคยข)ยกยฃ Type in some romaji and you will see the proper hiragana appear. Then hit the space bar and assuming you have cannaserver running, you should see a choice of kanji that can be selected with the arrow keys.

5.) Some caveats

A few difficulties that I’ve had are outlined below.

Gentoo. Make sure that you have the cjk and nls USE variables defined in /etc/make.conf when installing various packages, otherwise you will find that things like mutt and w3m won’t work with Japanese.

Slackware. Prior to Slackware 9.1 the langx script had to be modified.

#!/bin/bash
XMODIFIERS="@im=kinput2 LC_ALL=ja_JP ${1+"$@"} &

Also, if you didn’t install the glibc-i18n libraries during installation, you will have to grab the installation cd and install them. (They’re in the l directory. Note that is a lower case L, not the numeral “one”).

Free and NetBSD. In both of these, I never did get vi working correctly. I found that I had to use vim. (I didn’t find it necessary to use the Japanese one though, just took the one from /usr/ports/editors). Also, in NetBSD, one has to edit /usr/pkg/lib/X11/app-defaults/Rxvt. You will see several lines marked !Rxvt.multichar_encoding

Remove the ! from the line that has eucj at the end. Also, put a ! at the beginning of the top line, which ends with noenc.

Also, in NetBSD, you may get an error message when you start kinput2 that app-defaults can’t be loaded and you should modify your XFILESEARCHPATH. You can add it to your shell’s rc file. In Bourne style shells, such as sh, bash, ksh and zsh one would add

XFILESEARCHPATH=/usr/pkg/lib/X11/app-defaults/Kinput2; export
XFILESEARCHPATH

Doing a symbolic link also works.

cd /usr/X11R6/lib/X11/app-defaults
ln -s /usr/pkg/lib/X11/app-defaults/Kinput2 

In FreeBSD, there is a /usr/ports/japanese version of rxvt and w3m. Aside from those two, I didn’t find it necessary to use the Japanese version of any other programs

The rxvt terminal If installing rxvt from source (or using the package from various distros) you have to do the following when building the package.

./configure --enable-kanji --enable-xim


Congratulations, you’re done. Hopefully, you can now input Japanese in your *nix system.

References My page on Japanese input.
I have a far more detailed page on this, with links to other people’s pages as well.

Checklist for installing Gentoo 1.4 on an i686

    1. Obtain Gentoo and burn it to CD
      QND Gentoo.org
    2. Boot from Gentoo LiveCD, Disc 1
      QND Gentoo.org
    3. Set system data (and time)
      QND Gentoo.org
    4. Create partitions
      QND Gentoo.org
    5. Make filesystems QND
      Gentoo.org
    6. Mount filesystems QND
      Gentoo.org
    7. QND Extract the base system
      Make sure you are in the /mnt/gentoo directory, which is the mountpoint of your root filesystem:

      cd /mnt/gentoo
    8. Now, extract the Stage 3 base system tarball into the current directory:
      tar xvjpf /mnt/cdrom/stages/stage3-i686-*.tar.bz2
    9. Extract the Portage snapshot tarball into the usr/ directory:
      tar xvjf /mnt/cdrom/snapshots/portage-*.tar.bz2 -C usr
    10. Copy the distribution and GRP (Gentoo binary packages) files into your new Portage directory:
      cp -R /mnt/cdrom/distfiles usr/portage/distfiles
      cp -a /mnt/cdrom/packages usr/portage/packages
      

If you would like more information on this step, Gentoo.org

    1. QND Build a chroot jail
    2. Create a chroot jail for your new Gentoo system (yes, believe it or not, you almost have a fully functional system built in the /mnt/gentoo directory):
      chroot /mnt/gentoo /bin/bash
    3. Update your environment (to completely immerse yourself in the Matrix):
      env-update
      source /etc/profile

If you would like more information on this step, Gentoo.org

    1. QND Set your time zone
      Make a symbolic link (AKA symlink AKA soft link) from the zoneinfo file that correctly describes your time zone to /etc/localtime:

      ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime

      if you are in North America’s Eastern Standard Time zone. If you are in Ireland, you want to use zoneinfo/Eire; if in Japan, zoneinfo/Japan; if in California, zoneinfo/America/Los_Angeles; if in Bulgaria, zoneinfo/Europe/Sofia; and so on. You should be able to figure it out. ๐Ÿ™‚

If you would like more information on this step, Gentoo.org

    1. QND Create your /etc/fstab
      /etc/fstab tells Linux all it needs to know about your filesystems. Open it

      nano -w /etc/fstab

      and edit it (Nano is the GNU clone of Pico, if that helps you; Emacs / Readline style movement generally works; look at the bottom line of Nano for a quick keystroke reference) to look like this:

      # /etc/fstab: static file system information.
      #
      # noatime turns off atimes for increased performance (atimes normally aren't
      # needed; notail increases performance of ReiserFS (at the expense of storage
      # efficiency).  It is safe to drop the noatime options if you want and to 
      # switch between notail and tail freely.
      
      # <fs>           <mount point> <type>   <opts>          <dump/pass>
      
      # NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
      
      /dev/hda1        /boot         ext2        noauto          1 1
      /dev/hda3        /             reiserfs    defaults        0 0
      /dev/hda5        /opt          xfs         defaults        0 0
      /dev/hda6        /tmp          xfs         defaults        0 0
      /dev/hda7        /usr          xfs         defaults        0 0
      /dev/hda8        /var          xfs         defaults        0 0
      /dev/hda9        /home         xfs         defaults        0 0
      
      /dev/hda2        none          swap        sw              0 0
      
      /dev/cdroms/cdrom0 /mnt/cdrom  iso9660     noauto,ro,user  0 0
      
      none             /proc         proc        defaults        0 0

If you have a utility / diagnostics / whatever partition, remember to increment the partition number (and skip the dreaded hda4)!

If you would like more information on this step, Gentoo.org

    1. QND Compile a kernel
    2. This will be your first experience with emerge, which is the program used for manipulating Portage, the Gentoo package system. We will emerge (AKA install) the binary xfs-sources kernel:
      emerge -k xfs-sources

      The -k switch is what tells Portage to use a binary package as opposed to the preferred default source packages. (Though actually, the “binary” kernel package is not much different from the “source” one.)

    3. For some reason, some part of the GRP install seems to create a boot symlink to /boot in the /boot directory, which has the unfortunate result of creating an infinitely deep directory structure. Said foppery will prevent genkernel from installing the kernel. Kill the symlink:
      rm /boot/book
    4. Now, emerge the genkernel script and use it to compile and install your kernel:
      emerge -k genkernel
      genkernel

When genkernel finishes, make sure you have the following files in /boot:

/boot/System.map-version
/boot/kernel-version
      where

version

      is the Linux kernel version (e.g.

2.4.20

      ) plus the Gentoo kernel name (in this case

xfs

      ) and the Gentoo ebuild release (e.g

r3

      ). If these files do not exist, you will have to install the kernel manually:
version=`ls -1 /usr/src/ | grep linux- | awk -F'linux' '{ print $2 }'`
cp /usr/src/linux/System /boot/System.map$version
cp /usr/src/linux/arch/i386/boot/bzImage /boot/kernel$version

If you would like more information on this step, Gentoo.org

    1. QND Install a system logger and cron daemon
      You will install the most standard system logger, sysklogd, and cron daemon, vcron:

      emerge -k sysklogd vcron

      After the packages are installed, add them to the default run-level:

      rc-update add sysklogd default
      rc-update add vcron default

If you would like more information on this step, Gentoo.org

    1. QND Install all other necessary packages
    2. Since you have reiserfs and XFS filesystems, you should install the tools for both:
      emerge -k reiserfsprogs xfsprogs
    3. And if you are installing on a laptop, you will want to install the pcmcia-cs package and add it to the boot run-level:
      emerge -k pcmcia-cs
      rc-update add pcmcia boot

      (this will involve a compile–a binary package is not distributed on the LiveCD).

If you would like more information on this step, Gentoo.org

    1. QND

      14.) Set root’s password

      If you forget to set a password for the root account, you will not be able to login to your box! Do it now:

      passwd root

      Enter a good password, then enter it again for verification.

If you would like more information on this step, Gentoo.org

    1. QND Network setup
      If you are on a LAN, or are connected to the Internet by an Ethernet NIC (e.g. you have a cable or DSL modem), you will want to configure your network settings. If you dial up to the Internet, skip ahead to the next step.
    2. Set your hostname and domain name:
      echo 'hostname.domain.tld' >/etc/hostname
      echo 'domain.tld' >/etc/dnsdomainname
    3. Add at least one nameserver to your /etc/resolve.conf:
      echo 'nameserver 123.456.789.1' >/etc/resolv.conf
      echo 'nameserver 123.456.789.2' >>/etc/resolv.conf

      Please note that in the first step, you are truncating your /etc/resolv.conf, and in the second, you are appending to it (>> versus >)!

    4. Now, configure your primary Network Interface Card (NIC) by entering:
      nano -w /etc/conf.d/net

      Edit the file to look something like this (note that you only need to edit the lines coloured red):

      # /etc/conf.d/net:
      # $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/net,v 1.7 2002/11/18 19:39:22 azarah Exp $
      
      # Global config file for net.* rc-scripts
      
      # This is basically the ifconfig argument without the ifconfig $iface
      #
      iface_eth0="192.168.4.209 broadcast 192.168.4.255 netmask 255.255.255.0"
      #iface_eth1="207.170.82.202 broadcast 207.0.255.255 netmask 255.255.0.0"
      
      # For DHCP set iface_eth? to "dhcp"
      # For passing options to dhcpcd use dhcpcd_eth?
      #
      #iface_eth0="dhcp"
      #dhcpcd_eth0="..."
      
      # For adding aliases to a interface
      #
      #alias_eth0="192.168.0.3 192.168.0.4"
      
      # NB:  The next is only used for aliases.
      #
      # To add a custom netmask/broadcast address to created aliases,
      # uncomment and change accordingly.  Leave commented to assign
      # defaults for that interface.
      #
      #broadcast_eth0="192.168.0.255 192.168.0.255"
      #netmask_eth0="255.255.255.0 255.255.255.0"
      
      
      # For setting the default gateway
      #
      gateway="eth0/192.168.4.254"
      

      In the iface_eth0="192.168.4.209 broadcast 192.168.4.255 netmask 255.255.255.0" line, replace 192.168.4.209 with your IP address. Replace 192.168.4.255 with your broadcast address (which is usually just your IP address, except the number after the third dot is 255). If you know that you are not in a class C (or its CIDR equivalent, */24) network, replace 255.255.255.0 with your network mask. If you do not know these settings, consult your ISP, sysadmin, or local networking guru.

If you would like more information on this step, Gentoo.org

    1. QND Setup bootloader
    2. You will need to install a bootloader (in this case, GRUB) in order to boot into Linux:
      emerge -k grub
    3. Now, enter
      nano -w /boot/grub/grub.conf

      to create a GRUB configuration file. Edit it to look like this:

      default 0
      timeout 10
      splashimage=(hd0,0)/grub/splash.xpm.gz
      
      title=Gentoo 1.4 (Linux version)
      root (hd0,0)
      kernel (hd0,0)/kernel-version root=/dev/hda3
      initrd (hd0,0)/initrd-version

      where version is the Linux kernel version (e.g. 2.4.20) plus the Gentoo kernel name (in this case xfs) and the Gentoo ebuild release (e.g r3); i.e. the output of:

      version=`ls -1 /usr/src/ | grep linux- | awk -F'linux' '{ print $2 }'`

If you have a utility / diagnostics / whatever partition, you should change (hd0,0) to (hd0,1)!

The Gentoo instructions for this step (see below) have you enter (hd0,0)/boot instead of just (hd0,0)/. In my experience, GRUB cannot find any files prefixed with /boot. This makes sense in that (hd0,0) refers to the /boot partition, and is probably why the /boot/boot infinite symlink is created. What a kludge!

    1. To invoke the GRUB shell (one of the big reasons why it is the best bootloader, period), enter:
      grub --no-floppy

      You will be presented with a prompt:

          GNU GRUB  version 0.93  (640K lower / 3072K upper memory)
      
       [ Minimal BASH-like line editing is supported.  For the first word, TAB
         lists possible command completions.  Anywhere else TAB lists the possible
         completions of a device/filename. ]
      
      grub>

      To tell GRUB that your boot partition is the first partition (or second, if you have a utility / diagnostics / whatever partition) of the first hard drive, enter:

      root (hd0,0)

If you have a utility / diagnostics / whatever partition, you should change (hd0,0) to (hd0,1)!

GRUB will report:

 Filesystem type is ext2fs, partition type 0x83

To install GRUB onto the Master Boot Record (MBR) of your first hard drive, enter:

setup (hd0)

GRUB will report:

 Checking if "boot/grub/stage1" exists... yes
 Checking if "boot/grub/stage2" exists... yes
 Checking if "boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  16 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2
/boot/grub/grub.conf"... succeeded
Done.

To exit GRUB, enter:

quit

If you would like more information on this step, Gentoo.org

    1. QND Install XFree86
      If you are installing Gentoo on a server, you probably do not want to install X. Skip to the next step.QND

Using Portage and GRP, installing XFree86 is a simple as entering:

emerge -k xfree
      Again, the

-k

      flag tells

emerge

      to use binary packages when available.

If you would like more information on this step, Gentoo.org

    1. QND Stage a jail-break and reboot! Viva la revolucion!
      To escape from the chroot jail, enter:

      exit

      or hit Ctrl+d.

Unmount all of your filesystems:

cd /
for i in /mnt/gentoo/*; do
  umount /mnt/gentoo/$i;
done
umount -l /mnt/gentoo
      and reboot:
reboot

Make sure to remove the bootable CD as soon as you are able (i.e. right after the machine resets). If all is well, you will see a slick GRUB menu that will wait 10 seconds, then boot into your new Gentoo Linux system!

If you would like more information on this step, Gentoo.org

    1. QND Install useful software packages
      Login to the system with the root password that you set in Step 14QND.
    2. Insert the Gentoo LiveCD, Disc 2 into your CD-ROM drive and enter:
      cp /mnt/cdrom/packages/All/* usr/portage/packages/All/
      

      which will copy around 450MB worth of binary packages onto your hard drive. Don’t worry, it is only temporary. ๐Ÿ™‚

    3. Install a decent editor, vim, and sudo a package that lets you run commands with root privileges without having to be root (so you can avoid the onset of carpal tunnel due to typing su - a thousand times a day):
      emerge -k vim sudo gentoolkit

If you are installing Gentoo on a server, you are done. Create some user accounts and away you go! You should skip the rest of the steps in this guide.

    1. Now, install the window manager of your choice:
      • GNOME
        emerge -k gnome

        Open /etc/rc.conf in a text editor (e.g. nano or vim) and find the line:

        #DISPLAYMANAGER="xdm"

        Add a new line right below it:

        DISPLAYMANAGER="gdm"

        and save and exit the file.

      • GNOME
        emerge -k kde

        Open /etc/rc.conf in a text editor (e.g. nano or vim) and find the line:

        #DISPLAYMANAGER="xdm"

        Add a new line right below it:

        DISPLAYMANAGER="kdm"

        and save and exit the file.

    2. To install the Mozilla web browser, enter:
      emerge -k mozilla
    3. Generate an XFree86 configuration file:
      cd /etc/X11
      XFree86 -configure
      mv ~/XF86Config.new ./XF86Config-4

      Open the newly created /etc/X11/XF86Config-4 file in the editor of your choice (e.g. nano or vim) and find the lines:

      Section "Screen"
              Identifier "Screen0"

      Add a new line right beneath them:

      DefaultDepth    16

      for 16 million colours, or:

      DefaultDepth    24

      for 24 million colours.

Save the file and exit.

  1. To have X start automatically on boot, enter:
    rc-update add xdm default
  2. To start XFree86, using either GNOME or KDE, enter:
    /etc/init.d/xdm start

    If all is well, you should be presented with a graphical login screen. Voila, you have installed Gentoo with XFree86!

The Quick-N-Dirty Guide to Installing Gentoo Linux

The aim of this QND guide is to get you up and running the Gentoo linux distribution quickly on a i686 class computer (e.g. Pentium 2 or newer, including Pentium Pro, or AMD Athlon). To this end, the guide covers an install in which network access is not necessary, and thus not covered. If you would like the network to function during the install, see the Gentoo documentation. This guide is targetted at the Gentoo 1.4 release.

This guide is not exhaustive, nor will it result in the fastest / best possible Gentoo install. It does, however, get Gentoo installed on your box quickly without assaulting you with choices. I believe this makes it idea for a first Gentoo install. When you have learned a bit more about the system, you may want to re-install, or re-emerge your base system. The great thing about Gentoo is that you can take a system that “just boots”, and customize it completely to your needs and architecture.

1.) Obtain Gentoo and burn it to CD

If you have access to a fast Internet connexion and a CD burner (or know someone who does), grab the latest Gentoo LiveCDs from:

http://gentoo.oregonstate.edu/releases/x86/1.4/livecd/i686/

You will want to download both .iso files and then burn a CD of each (i.e. this will result in you having a LiveCD Disc 1 CD and a LiveCD Disc 2 CD).

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

2.) Boot from Gentoo LiveCD, Disc 1

On most modern computers, this is as simple as putting the CD in your CD-ROM drive and [re-]booting the computer. If you try this and it does not boot from the CD-ROM, make sure you have Disc 1 in (Disc 2 is not bootable), and if you do, you may need to twiddle settings in your BIOS to boot off a CD. If you do not know how to do that, ask your local computer expert.

When you boot from the CD, you will be presented with some options. If you have an SMP system (i.e. you have more than one CPU), type smp and hit enter. Most people just want to hit enter here. You will see a splash screen with a progress bar, and then will be logged in as root. You will know that this has happened when the cursor blinks after a prompt that looks like this:

cdimage root #

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

3.) Set system data (and time)

Enter:

date

If the resulting date and time are correct, move on to the next step. If they are incorrect, enter:

date MMDDhhmmYYYY

where MM is the two-digit month (e.g. November is 11), DD is the two-digit day of the month (e.g. 01, 09, 13, etc), hh is the hour, in 24-hour time (e.g. 7 AM is 07, 7 PM is 19, etc), mm is the two-digit minute (e.g. 05, 15, etc), and YYYY is the four-digit year (e.g. 2003).

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

4.) Create partitions

Before we can create filesystems, we must physically partition up the hard drive. This guide will assume that you have only one hard drive (or are using only one hard drive for Gentoo), that it is an IDE drive, and that it is the your first logical IDE drive (i.e. /dev/hda. If you do not understand any of that, don’t worry, the setup just described is correct for 99% of personal computers. If you know that your setup is different, you also probably know how to alter the next bits of this guide to work with your setup (e.g. if you have a SCSI drive, change all of the /dev/hdas in the next few steps to /dev/sda). If you don’t, consult your local Unix expert or:

Filesystems, partitions and block devices

!!! DANGER WILL ROBINSON !!! If you have any data that you love, back it up before proceeding. The next step in this guide will destroy *ALL* data on your system, *including* any currently installed Operating System!

Still reading? Good. ๐Ÿ™‚ Enter:

fdisk /dev/hda

which will open the (somewhat arcane) partition editor. You will see something like:

The number of cylinders for this disk is set to 4863.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):

and a blinking cursor. Try not to be afraid.

Enter p at the prompt to display the current partition table, which will look something like:

Disk /dev/hda: 40.0 GB, 40000000000 bytes
255 heads, 63 sectors/track, 4863 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1   *         1         7     56196   de  Dell Utility
/dev/hda2             8        24    136552+  83  Win95 FAT32

we now want to delete all of the current partitions, except for the first one if it happens to be labelled as a “utility” or “diagnostics” partition (in this example, we do not want to delete the first partition, because it is labelled “Dell Utility”).

To delete a partition, enter d. You will be prompted for a partition number. You should enter 1 unless your first partition is labelled utility / diagnostics / whatever, in which case you should enter 2. Now, enter d again, and enter the number of the next partition. Repeat until you get a

No partition is defined yet!

error.

Now, enter p. You should see:

Disk /dev/hda: 40.0 GB, 40000000000 bytes
255 heads, 63 sectors/track, 4863 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System

unless you have a utility / diagnostics / whatever partition, in which case it will be listed.

It is now time to start creating partitions. This guide will not (as some popular *koff* Mandrake Red Hat *koff* Linux distros tend to do) create one massive root partition. Instead, we will hold to the assertion that Linux is Unix and do things right. We will assume that your hard drive is at least 8GB in size. If it is smaller, you probably should not be using this document to install Gentoo.

Enter n to create a new partition. When asked:

Command action
   e   extended
   p   primary partition (1-4)

enter p, and then, when prompted for a partition number, enter 1, unless you have a utility / diagnostics / whatever partition, in which case you should enter 2. When prompted to enter the first cylinder, press enter to accept the default. Finally, you will be prompted to enter the last cylinder (only if you have a PhD in mathematics) or a size. This partition shall be your /boot partition, so enter +64M to make it 64 megabytes large.

Now, enter n again to create your swap partition. Enter p to make it a primary partition, and 2 to make it the second partition, unless you have a utility / diagnostics / whatever partition, in which case you should enter 3. Enter +512M to make your swap partition 512 megabytes (if you know how big your swap partition should be, feel free to ignore this recommendation and use your own size.

Now, we need to create the root partition. For those of you who do not have utility / diagnostics / whatever partitions, repeat the partition creation process as above, and make the root partition 256MB. If you have a utility / diagnostics / whatever partition, skip ahead to the next paragraph, then create a root partition as detailed there.

It is time to create our extended partition that will hold the rest of the partition. Enter n at the main menu as usual, but when asked whether the partition should be extended or primary, enter e for extended. When asked for the first cylinder, press enter to accept the defaults. Also press enter to accept the defaults when asked about the last cylinder. This will create an extended partition that takes up the rest of the disk. If you have not yet created your root partition, (becuase you have a utility / diagnostics / whatever partition), do it now. Note that you will not be asked what kind of partition to create, you will just enter the first and last cylinder (size) information. Make the root partition 256MB.

Create the remaining partitions, as above, except note that you will not be asked what kind of partition to create, you will just enter the first and last cylinder (size) information. You will need, in this order: /opt, 512MB; /tmp, 512MB; /usr, 4096MB; /var, 1024MB; and /home, all remaining space on the disk (accept defaults for both first and last cylinders).

Now, enter p at the main menu to display the current partitions. It should look something like:

Disk /dev/hda: 100.0 GB, 100030242816 bytes
255 heads, 63 sectors/track, 12161 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1             1         9     72261   83  Linux
/dev/hda2            10        72    506047+  83  Linux
/dev/hda3            73       104    257040   83  Linux
/dev/hda4           105     12161  96847852+   5  Extended
/dev/hda5           105       167    506016   83  Linux
/dev/hda6           168       230    506016   83  Linux
/dev/hda7           231       729   4008186   83  Linux
/dev/hda8           730       854   1004031   83  Linux
/dev/hda9           855     12161  90823446   83  Linux

Note that if you have a utility / diagnostics / whatever partition, everything will be shifted down one and the root partition will be in the extended partition.

Now, enter w to write your new partitioning scheme to the disk and exit fdisk.

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

5.) Make filesystems

If you have a utility / diagnostics / whatever partition, increment all partition names in this section by one (e.g. if /dev/hda1 is written, use /dev/hda2 instead) unless it is /dev/hda3. Here you must use /dev/hda5 instead (because of the extended partition).

Likewise, if you have a SCSI disk, substitute sda wherever hda is written.

You will make your /boot filesystem ext2, which is the old standby of Linux filesystems. We need not worry about a journalling filesystem for /boot since it should almost never be mounted. To create the filesystem, enter:

mke2fs /dev/hda1

Next, initialise your swap partition:

mkswap /dev/hda2

You will make your root partition reiserfs, since it is good at handling the large number of small files that tend to abound on root partitions:

mkreiserfs /dev/hda3

If you have a utility / diagnostics / whatever partition, this should be hda5!

The rest of your partitions will be XFS, which is a good preforming general-purpose journalling filesystem:

for i in `seq 5 9`; do mkfs.xfs -f /dev/hda$i; done

If you have a utility / diagnostics / whatever partition, this should be `seq 6 10`!

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

6.) Mount filesystems

If you have a utility / diagnostics / whatever partition, increment all partition names in this section by one (e.g. if /dev/hda1 is written, use /dev/hda2 instead) unless it is /dev/hda3. Here you must use /dev/hda5 instead (because of the extended partition).

Likewise, if you have a SCSI disk, substitute sda wherever hda is written.

First, activate your swap space:

swapon /dev/hda2

If you have a utility / diagnostics / whatever partition, this should be hda3!

Now, mount your root partition:

mount /dev/hda3 /mnt/gentoo

If you have a utility / diagnostics / whatever partition, this should be hda5!

Change to your newly mounted root filesystem

cd /mnt/gentoo

and create the mountpoints for the rest of your filesystems:

for i in boot home opt proc tmp usr var; do mkdir $i; done

Now, mount all of the remaining filesystems:

mount /dev/hda1 boot
mount /dev/hda5 opt
mount /dev/hda6 tmp
mount /dev/hda7 usr
mount /dev/hda8 var
mount /dev/hda9 home

If you have a utility / diagnostics / whatever partition, remember to increment the partition number (and skip the dreaded hda4)!

Finally, mount the /proc partition on proc–we will need it later:

mount -t proc /proc proc

And now is as good a time as any to set the permissions on our newly mounted /tmp partition correctly:

chmod 1777 tmp

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

7.) Extract the base system

Make sure you are in the /mnt/gentoo directory, which is the mountpoint of your root filesystem:

cd /mnt/gentoo

Now, extract the Stage 3 base system tarball into the current directory:

tar xvjpf /mnt/cdrom/stages/stage3-i686-*.tar.bz2

Extract the Portage snapshot tarball into the usr/ directory:

tar xvjf /mnt/cdrom/snapshots/portage-*.tar.bz2 -C usr

Copy the distribution and GRP (Gentoo binary packages) files into your new Portage directory:

cp -R /mnt/cdrom/distfiles usr/portage/distfiles
cp -a /mnt/cdrom/packages usr/portage/packages

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

8.) Build a chroot jail

Create a chroot jail for your new Gentoo system (yes, believe it or not, you almost have a fully functional system built in the /mnt/gentoo directory):

chroot /mnt/gentoo /bin/bash

Update your environment (to completely immerse yourself in the Matrix):

env-update
source /etc/profile

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

9.) Set your time zone

Make a symbolic link (AKA symlink AKA soft link) from the zoneinfo file that correctly describes your time zone to /etc/localtime:

ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime

if you are in North America’s Eastern Standard Time zone. If you are in Ireland, you want to use zoneinfo/Eire; if in Japan, zoneinfo/Japan; if in California, zoneinfo/America/Los_Angeles; if in Bulgaria, zoneinfo/Europe/Sofia; and so on. You should be able to figure it out. ๐Ÿ™‚

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

10.) Create your /etc/fstab

/etc/fstab tells Linux all it needs to know about your filesystems. Open it

nano -w /etc/fstab

and edit it (Nano is the GNU clone of Pico, if that helps you; Emacs / Readline style movement generally works; look at the bottom line of Nano for a quick keystroke reference) to look like this:

# /etc/fstab: static file system information.
#
# noatime turns off atimes for increased performance (atimes normally aren't
# needed; notail increases performance of ReiserFS (at the expense of storage
# efficiency).  It is safe to drop the noatime options if you want and to 
# switch between notail and tail freely.

# <fs>           <mount point> <type>   <opts>          <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.

/dev/hda1        /boot         ext2        noauto          1 1
/dev/hda3        /             reiserfs    defaults        0 0
/dev/hda5        /opt          xfs         defaults        0 0
/dev/hda6        /tmp          xfs         defaults        0 0
/dev/hda7        /usr          xfs         defaults        0 0
/dev/hda8        /var          xfs         defaults        0 0
/dev/hda9        /home         xfs         defaults        0 0

/dev/hda2        none          swap        sw              0 0

/dev/cdroms/cdrom0 /mnt/cdrom  iso9660     noauto,ro,user  0 0

none             /proc         proc        defaults        0 0

If you have a utility / diagnostics / whatever partition, remember to increment the partition number (and skip the dreaded hda4)!

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

11.) Compile a kernel

This will be your first experience with emerge, which is the program used for manipulating Portage, the Gentoo package system. We will emerge (AKA install) the binary xfs-sources kernel:

emerge -k xfs-sources

The -k switch is what tells Portage to use a binary package as opposed to the preferred default source packages. (Though actually, the “binary” kernel package is not much different from the “source” one.)

For some reason, some part of the GRP install seems to create a boot symlink to /boot in the /boot directory, which has the unfortunate result of creating an infinitely deep directory structure. Said foppery will prevent genkernel from installing the kernel. Kill the symlink:

rm /boot/boot

Now, emerge the genkernel script and use it to compile and install your kernel:

emerge -k genkernel
genkernel

When genkernel finishes, make sure you have the following files in /boot:

/boot/System.map-version
/boot/kernel-version

where version is the Linux kernel version (e.g. 2.4.20) plus the Gentoo kernel name (in this case xfs) and the Gentoo ebuild release (e.g r3). If these files do not exist, you will have to install the kernel manually:

version=`ls -1 /usr/src/ | grep linux- | awk -F'linux' '{ print $2 }'`
cp /usr/src/linux/System /boot/System.map$version
cp /usr/src/linux/arch/i386/boot/bzImage /boot/kernel$version

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

12.) Install a system logger and cron daemon

You will install the most standard system logger, sysklogd, and cron daemon, vcron:

emerge -k sysklogd vcron

After the packages are installed, add them to the default run-level:

rc-update add sysklogd default
rc-update add vcron default

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

13.) Install all other necessary packages

Since you have reiserfs and XFS filesystems, you should install the tools for both:

emerge -k reiserfsprogs xfsprogs

And if you are installing on a laptop, you will want to install the pcmcia-cs package and add it to the boot run-level:

emerge -k pcmcia-cs
rc-update add pcmcia boot

(this will involve a compile–a binary package is not distributed on the LiveCD).

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

14.) Set root’s password

If you forget to set a password for the root account, you will not be able to login to your box! Do it now:

passwd root

Enter a good password, then enter it again for verification.

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

15.) Network setup

If you are on a LAN, or are connected to the Internet by an Ethernet NIC (e.g. you have a cable or DSL modem), you will want to configure your network settings. If you dial up to the Internet, skip ahead to the next step.

Set your hostname and domain name:

echo 'hostname.domain.tld' >/etc/hostname
echo 'domain.tld' >/etc/dnsdomainname

Add at least one nameserver to your /etc/resolve.conf:

echo 'nameserver 123.456.789.1' >/etc/resolv.conf
echo 'nameserver 123.456.789.2' >>/etc/resolv.conf

Please note that in the first step, you are truncating your /etc/resolv.conf, and in the second, you are appending to it (>> versus >)!

Now, configure your primary Network Interface Card (NIC) by entering:

nano -w /etc/conf.d/net

Edit the file to look something like this (note that you only need to edit the lines coloured red):

# /etc/conf.d/net:
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/net,v 1.7 2002/11/18 19:39:22 azarah Exp $

# Global config file for net.* rc-scripts

# This is basically the ifconfig argument without the ifconfig $iface
#
iface_eth0="192.168.4.209 broadcast 192.168.4.255 netmask 255.255.255.0"
#iface_eth1="207.170.82.202 broadcast 207.0.255.255 netmask 255.255.0.0"

# For DHCP set iface_eth? to "dhcp"
# For passing options to dhcpcd use dhcpcd_eth?
#
#iface_eth0="dhcp"
#dhcpcd_eth0="..."

# For adding aliases to a interface
#
#alias_eth0="192.168.0.3 192.168.0.4"

# NB:  The next is only used for aliases.
#
# To add a custom netmask/broadcast address to created aliases,
# uncomment and change accordingly.  Leave commented to assign
# defaults for that interface.
#
#broadcast_eth0="192.168.0.255 192.168.0.255"
#netmask_eth0="255.255.255.0 255.255.255.0"


# For setting the default gateway
#
gateway="eth0/192.168.4.254"
      

In the iface_eth0="192.168.4.209 broadcast 192.168.4.255 netmask 255.255.255.0" line, replace 192.168.4.209 with your IP address. Replace 192.168.4.255 with your broadcast address (which is usually just your IP address, except the number after the third dot is 255). If you know that you are not in a class C (or its CIDR equivalent, */24) network, replace 255.255.255.0 with your network mask. If you do not know these settings, consult your ISP, sysadmin, or local networking guru.

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

16.) Setup bootloader

You will need to install a bootloader (in this case, GRUB) in order to boot into Linux:

emerge -k grub

Now, enter

nano -w /boot/grub/grub.conf

to create a GRUB configuration file. Edit it to look like this:

default 0
timeout 10
splashimage=(hd0,0)/grub/splash.xpm.gz

title=Gentoo 1.4 (Linux version)
root (hd0,0)
kernel (hd0,0)/kernel-version root=/dev/hda3
initrd (hd0,0)/initrd-version

where version is the Linux kernel version (e.g. 2.4.20) plus the Gentoo kernel name (in this case xfs) and the Gentoo ebuild release (e.g r3); i.e. the output of:

version=`ls -1 /usr/src/ | grep linux- | awk -F'linux' '{ print $2 }'`

If you have a utility / diagnostics / whatever partition, you should change (hd0,0) to (hd0,1)!

The Gentoo instructions for this step (see below) have you enter (hd0,0)/boot instead of just (hd0,0)/. In my experience, GRUB cannot find any files prefixed with /boot. This makes sense in that (hd0,0) refers to the /boot partition, and is probably why the /boot/boot infinite symlink is created. What a kludge!

To invoke the GRUB shell (one of the big reasons why it is the best bootloader, period), enter:

grub --no-floppy

You will be presented with a prompt:

    GNU GRUB  version 0.93  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename. ]

grub>

To tell GRUB that your boot partition is the first partition (or second, if you have a utility / diagnostics / whatever partition) of the first hard drive, enter:

root (hd0,0)

If you have a utility / diagnostics / whatever partition, you should change (hd0,0) to (hd0,1)!

GRUB will report:

 Filesystem type is ext2fs, partition type 0x83

To install GRUB onto the Master Boot Record (MBR) of your first hard drive, enter:

setup (hd0)

GRUB will report:

 Checking if "boot/grub/stage1" exists... yes
 Checking if "boot/grub/stage2" exists... yes
 Checking if "boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  16 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2
/boot/grub/grub.conf"... succeeded
Done.

To exit GRUB, enter:

quit

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

17.) Install XFree86

If you are installing Gentoo on a server, you probably do not want to install X. Skip to the next step.

Using Portage and GRP, installing XFree86 is a simple as entering:

emerge -k xfree

Again, the -k flag tells emerge to use binary packages when available.

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

18.) Stage a jail-break and reboot! Viva la revolucion!

To escape from the chroot jail, enter:

exit

or hit Ctrl+d.

Unmount all of your filesystems:

cd /
for i in /mnt/gentoo/*; do
  umount /mnt/gentoo/$i;
done
umount -l /mnt/gentoo
      

and reboot:

reboot

Make sure to remove the bootable CD as soon as you are able (i.e. right after the machine resets). If all is well, you will see a slick GRUB menu that will wait 10 seconds, then boot into your new Gentoo Linux system!

If you would like more information on this step, view the relevant section of the Gentoo Linux 1.4 Installation Instructions.

19.) Install useful software packages

Login to the system with the root password that you set in Step 14.

Insert the Gentoo LiveCD, Disc 2 into your CD-ROM drive and enter:

cp /mnt/cdrom/packages/All/* usr/portage/packages/All/

which will copy around 450MB worth of binary packages onto your hard drive. Don’t worry, it is only temporary. ๐Ÿ™‚

Install a decent editor, vim, sudo a package that lets you run commands with root privileges without having to be root (so you can avoid the onset of carpal tunnel due to typing su - a thousand times a day), and the Gentool Toolkit:

emerge -k vim sudo gentoolkit

If you are installing Gentoo on a server, you are done. Create some user accounts and away you go! You should skip the rest of the steps in this guide.

Now, install the window manager of your choice:

  • GNOME
    emerge -k gnome
    

    Open /etc/rc.conf in a text editor (e.g. nano or vim) and find the line:

    #DISPLAYMANAGER="xdm"
    

    Add a new line right below it:

    DISPLAYMANAGER="gdm"
    

    and save and exit the file.

  • KDE
    emerge -k kde
    

    Open /etc/rc.conf in a text editor (e.g. nano or vim) and find the line:

    #DISPLAYMANAGER="xdm"
    

    Add a new line right below it:

    DISPLAYMANAGER="kdm"
    

    and save and exit the file.

To install the Mozilla web browser, enter:

emerge -k mozilla

Generate an XFree86 configuration file:

cd /etc/X11
XFree86 -configure
mv ~/XF86Config.new ./XF86Config-4

Open the newly created /etc/X11/XF86Config-4 file in the editor of your choice (e.g. nano or vim) and find the lines:

Section "Screen"
        Identifier "Screen0"

Add a new line right beneath them:

DefaultDepth    16

for 16 million colours, or:

DefaultDepth    24

for 24 million colours.

Save the file and exit.

To have X start automatically on boot, enter:

rc-update add xdm default

To start XFree86, using either GNOME or KDE, enter:

/etc/init.d/xdm start

If all is well, you should be presented with a graphical login screen. Voila, you have installed Gentoo with XFree86!

 

The Quick-N-Dirty Guide to Samba

The aim of this QND guide is to get you up and running quickly with samba. There will be far more how than why here.

This guide is aimed towards the home networker who wants to use his Linux or FreeBSD box as a file server. This article only covers setting up the *nix box so that files can be shared from it.

Because of the many differences in which each distribution and FreeBSD handle samba, we are making a few assumptions here. We are assuming that you understand your machine’s firewall and how to allow a new port to go through it. We are assuming that you know how to start a service on bootup. If you don’t know how to start a service at bootup, then check out our QND guide on running a program when the machine boots. In Samba’s case, although some distros will start both daemons with a samba command the two daemons you want are the smbd and nmbd ones.

A great many things can go wrong with samba. This guide is making the assumption that they won’t. ๐Ÿ™‚ However, there will be some links at the end, to more involved documentation and troubleshooting pages.

1.) Do you have Samba?


In a command shell type

which smbd
which nmbd

This must be done as root. It won’t work with sudo nor will it work with a simple su. It will, however, work with su -. This should return the path to the two programs, probably /usr/sbin/. (In FreeBSD probably /usr/local/sbin/). If it finds it, go to step 3. If it doesn’t go to step 2.

2.) Installing Samba


Go to the QND software guide for information about getting and installing . We’ll wait. If it turns out that is not included with your particular flavor of Linux then try their home page which has rpms and source code.

3.) Configuring Samba


Firstly, find your /etc/smb.conf. This will vary upon O/S and distro. Usually, there will be an /etc/smb.conf or /etc/samba/smb.conf. In FreeBSD it will be in /usr/local/etc. (It might only be in /userports/net/samba/work/samba-versionnumber/examples/sample) There may only be a file called something like smb.conf.sample. If that’s the case, copy the file to smb.conf

cp smb.conf.sample smb.conf

and you will have a file to edit.

In the top section, [global] you’ll find a line

workgroup = MYGROUP

Change this to the name of your workgroup or domain. In MS, the default name is WORKGROUP. (Gentoo Linux actually has this name as WORKGROUP by default.) You may also choose to rename your MS machines to MYGROUP–the point here is that they have to have the same name.

Next look for a line saying

;encrypt passwords = yes

Again, Gentoo has this uncommented. If it’s commented by the ; in your smb.conf, uncomment it unless you’re running Windows 95 or Windows 98 pre-second edition.

In samba 3.x this is no longer necessary, it works with encrypted passwords by default.

For purposes of example, we’re going to assume that you have a user named john on the MS box with a password of 1234. So, now add that user name to your Linux or FreeBSD box. As there are various commands to do this, and they vary with distribution, hopefully, it is something that you already know how to do. For example, in Gentoo it would be

useradd -m -s /bin/bash john

You can give him a password or not, depending upon your needs, distribution, etc. Again using Gentoo as an example, if he has no password, he won’t be able to log into the Linux box–other distros might allow him to log in with a blank password, in which case, you obviously want to give him a password. Now, we have to add john to the smbpasswd file

smbpasswd -a john

It will ask for the new password and then ask you to type it again. This password has to be the same as it is for user john on the MS box.

Note that in samba 3.x smbpasswd is deprecated. It is suggested that you use tdbsam. Rather than smbpasswd -a john the syntax is

pdbedit -a -u john

One other important point–many distributions, such as RedHat, have a default firewall that will block samba. Firewalls are beyond the scope of this QND guide, but if you are using RedHat, you can use their builtin lokkit to allow samba to work. Regardless of distro, you have to allow both tcp and udp on ports 137:139.

Now we can start samba–again, this depends very much upon distro–in Gentoo it’s

/etc/init.d/samba start

To have it run at boot

rc-update add samba default

With RedHat, you can use their ntsysv or chkconfig. You may have to start both smbd and nmbd, or their later configurations might simply have a samba command. In FreeBSD it will place a script in /usr/local/etc/rc.d. However, comments in the script indicate that you have to add to /etc/rc.conf

samba_enable=”YES”

Again, hopefully, you already know how to start services at boot in your distro of choice. To simply start it for testing, a simple

/usr/sbin/smbd
/usr/sbin/nmbd

will usually be sufficient. (If it’s somewhere else, such as FreeBSD’s /usr/local/sbin, then of course, use that path name)

4) Test Samba


Firstly, at a command prompt, type

testparm

This simply tests for any grievious syntax errors. Hopefully, it won’t show any. Now fire up the Windows box. Log on as user john with the password of 1234. Open up Network Neighborhood or My Network Places and see if you can find the samba box. If so, there should be a folder for the user john. If you can put a text document in there and save it, you have been successful.

Congratulations, you should be done.

However, as mentioned before, many things can go wrong with Samba. If you aren’t able to read or write to john’s folder on the Linux box, you can try my samba page which goes into more detail. That page also has links to the online O’Reilly guide.

There is usually a trouble shooting guide in the samba docs that are included with the program. In FreeBSD-5.3, they’re in /usr/local/share/doc/samba. (The troubleshooting one is in the Samba-HOWTO-Collection.pdf, in a section called, interestingly enough, Trouble Shooting.) ๐Ÿ™‚

References


man samba
man smb.conf
samba home page

The Quick-N-Dirty Guide to Mutt

The aim of these QND guides is to get you up and running quickly. Therefore, there is going to be little explanation of why things work. However, by the end of this article, you will be able to use mutt to send and receive email.

The easiest way to get mail in mutt is to use getmail. So, before starting this guide, take a look at the QND getmail guide. It will only take you a few minutes. Don’t worry, we’ll wait.

(The author greatly prefers getmail to the better known fetchmail. However, for those who must, there is also a QND Fetchmail guide.)

Now to set up mutt. Open up your favorite text editor and make a .muttrc file (note the dot before it).

folder-hook . “my_hdr From: John <john@isp.com>”

The example given is the absolute minimum for a .muttrc. There are often examples, and the references given below go into much greater detail.

Most distributions have a system wide /etc/Muttrc file. It’s always good to take a look at that file to see what is there. (On some distros it’s in /etc/Mutt/muttrc or something similar, but you should be able to find it.

Note that you don’t have to have sendmail, postfix or whatever your MTA is running as a daemon to use mutt. Mutt will call it when necessary.
(Actually, in my experience, postfix can be iffy–sometimes it will work if postfix isn’t started and other times it won’t. I’ve also found that in FreeBSD, this doesn’t seem to be the case. If sendmail isn’t started, the messages will be queued but not sent. However, if you’re using ssmtp as a sendmail replacement, done by typing make replace in /usr/ports/mail/ssmtp, you don’t have to call it before sending mail)

Aliases

The aliases file is comparable to an address book. As this is the QND guide, we’re only covering how to add an address of someone sending you mail.

Open up your .muttrc file and add these two lines

set alias_file=~/.mutt_aliases
source ~/.mutt_aliases

This tells mutt where to look for your aliases. This will serve as an address book. Now we create our .mutt_aliases file.

touch .mutt_aliases

Now, if you receive mail from someone and want to add them to your aliases, while on their email hit the a key. Mutt will begin a dialog. It’s usually safe to accept the defaults save for the last question, which is something like save to /.mutt_aliases?
For that question, change it to ~/.mutt_aliases. If, however, it says save it to /home/john/.mutt_aliases then it’s safe to accept it.

This should enable you to get mutt up and running. Mutt is a very powerful and configurable client and there countless other options. For further reading you can start with a more detailed page of mine and, of course, the mutt manual which should probably be on your machine in /usr/share/doc/mutt[version number]. It’s also available on line here.

The QND Guide to Starting Programs at Boot

Many programs, such as CUPS, samba, Canna and the like are programs that you wish to start running when the machine boots. Most operating systems have their own way of doing this. This QND guide covers how to do it in various Linux distributions, as well as FreeBSD and NetBSD.

In a pinch, one can always add a line to their /etc/rc.d/rc.local file (sometimes /usr/local/etc/rc.d, and sometimes /etc/rc.local) giving the full path to the program. For instance, if you install cannaserver from the vanilla version we provide, (see the QND Guide to Using Japanese in *nix) you could simply add the following line to ArchLinux’s /etc/rc.local

/usr/sbin/cannaserver

However, as most distributions provide a way to more gracefully do this, it is worth learning.

RedHat

RedHat (and we are including Fedora in this) has a simple ncurses program called ntsysv. If you type

ntsysv

at a command prompt, a dialog comes up with various services. Hitting the space bar while a particular service is hightlighted will add or remove an asterisk from it, determining whether or not it should be started at boot.

They also have a little program called chkconfig. The syntax is as follows, using sendmail as an example

chkconfig --level 35 sendmail on

To stop it from running at startup simply change the on to off. The level part of the command refers to run levels–in RH level 3 is multiuser non-graphic and level 5 is graphic.

Slackware

Slackware has an /etc/rc.d/rc.M file. A sample from it goes

if [ -x /etc/rc.d/rc.sendmail]; then
. /etc/rc.d/rc.sendmail start
fi

So, one can add a program to this. Again, going back to our cannaserver program, one can simply add the lines

if [ -x /usr/sbin/cannaserver]; then
. /usr/sbin/cannaserver
fi

If one looks at the file, they can see other examples. There are other ways to do it, including echoing “Starting the cannaserver” before starting it, etc.

Gentoo

When a package is emerged in Gentoo, one can usually simply add it with the rc-update command. Canna is one of those that can be added. In this case

rc-update add canna default

ArchLinux

ArchLinux has an /etc/rc.conf file. In there is the line

DAEMONS=(!pcmcia network crond inetd)

One simply adds the daemons they want run at boot to that line. For example, if you want the sshd daemon to run at boot, change that line to read

DAEMONS=(!pcmcia network crond inetd sshd)

(Note that putting ! in front a daemon’s name disables it–for example, in the default the pcmcia daemon is prefixed with a !, meaning it will not start at boot).

FreeBSD

FreeBSD puts most programs that don’t come with the base system into either /usr/local/bin or /usr/X11R6/bin. In almost all cases, a FreeBSD port also installs a script in /usr/local/etc/rc.d. One will usually, after installing canna for example, find that a little shell script starting the daemon is in /usr/local/etc/rc.d. Continuing with our canna example, one finds that as long as it was installed from ports, there is a script in there called canna.sh.sample. If you wish canna to run at boot, simply remove the “sample” from it.

cd /usr/local/etc/rc.d
mv canna.sh.sample canna.sh

Recently, many of the /usr/local/etc/rc.d script will have commented instructions that one should add a line to /etc/rc.conf. For example, with samba, one adds

samba_enable="YES"

so one should take a quick look at the .sh script to see if this is necessary.

NetBSD

NetBSD is quite similar to FreeBSD in this respect, however the startup script is usually found in
/usr/pkg/local/rc.d

It is hoped the above will enable you to get a program to run at boot without problems.

The Quick-N-Dirty Guide to fdisk

The aim of this QND guide is to get you up and running quickly with fdisk. There will be far more how than why here.

Although most distros usually have their own graphical partitioning tools, it is good to be familiar with fdisk. One never knows when they may have to use it–sometimes graphical tools don’t work properly.

Many, if not most, distributions also now have cfdisk which is somewhat easier to use. However, there are times when cfdisk too, won’t work and fdisk will.

1.) Do you have fdisk?

You should definitely have fdisk available. If not, something is probably wrong with your system. However it is one of those commands that is run by root or with root privilege. Therefore, it might not be visible (depending upon distribution) as normal user. You may have to either log in as root or do

su –

instead of using sudo or a simple su.

2.) Using fdisk

In this case, the easiest way to explain fdisk’s use is by example. We will assume that you have a 10 gig hard drive. 3 gigs are devoted to Windows and now you wish to install Linux on the other 7 gigs. For purposes of this example, we will create an extended partition and inside of it create 3 logical partitions. One will be swap, one will be a small /boot partition and the last will use up the remaining free space.

Although most versions of LILO and GRUB will, on modern computers, now boot beyond the 1024th disk cylinder, we’re keeping our boot partition within the first 4 gigs of the drive. (There are other reasons to keep a separate /boot partition, but it often simply depends upon personal perference. At any rate, that is beyond the scope of this guide.)

First, we see what we have

fdisk /dev/hda

This will start the fdisk program. Now, to see what is already there, type

p

The p stands for print, and will show you what exists. At present, you should only have one partition, the one that is holding Windows. (I’ve found that Windows seems to partition disks differently–with Slackware, for example, I also get a warning that the partition doesn’t end where it should–however, it hasn’t caused me problems, so, I shrug it off.)

Now, we want to refresh our memory on the commands so we type

m

(In this case, I assume it stands for manual). It will show me the possible commands.

Firstly, I want to create my swap partition. One could make a new primary partition, but I don’t find it necessary so, I type

n

I’m then asked do I want a primary partition or extended partition. I’m told to type p for primary or e for extended. I choose e for extended. Next I’m asked for a number for the partition, usually given the choice of 1-4. I pick 2 as it’s the next partition.

It will then ask for the first cylinder, showing the default, which is the next cylinder next to the already existing Windows partition. Hit enter to accept the default. Then it asks for the last cylinder–the default is the end of the drive and again I hit enter to accept it.

I then again type p to verify that I did what I wanted. Hopefully it is showing me what I asked for.

Now I type n again for a new partition. This will be my swap partition. I’m asked do I want to make a primary one or a logical one. As you might guess, I’m told to type p for primary and l for logical. I choose l, as I’m making a partition within the extended partition.

I’m then informed that the numbers will begin at 5. I’m then asked for the first cylinder–again I choose the default, which is the first cylinder available.

I’m then asked for the last cylinder–however, I’m also given the option of specifying my size in Megabytes by typing + (desired size)M. I want my swap partition to be 128 Megabytes so I type

+128M

I hit enter. One could type p again to verify that it’s going the way you want it to, that’s up to you. Doing that, I find that this 128 Meg partition is Linux native, which I don’t want, I want Linux swap. So, I then type

t

It will ask me which partition’s type do I want to change. I pick 5, which is my first logical partition. (I can also discover this with the p command–the partition will be /dev/hda5). I’m then asked for the type, and told I can type L for a list of hex codes. I already know that swap is hex code 82, so I type

82

Now, I’m making my boot partition. This can be of various sizes–RH recommends 16 Megs, so I make it 20 Megs just in case. So, I begin by typing

n

Again, I’m presented with the choice for logical or primary and choose logical. Again I’m given the default 1st cylinder, which I accept and again asked for the last cylinder, with the option to specify size in Megabytes.

I type

+20M

This gives me a 20 meg partition to use as boot. It might be slightly different, as like the fdisk found in DOS fdisk will determine cylinder boundries and adjust accordingly.

Once again I type p to see what I have. I now see one Windows partition, and one extended partition. The extended partition has one 128 meg logical partition as Linux swap and a 20 meg Linux native partition.

So, once again, we type n to create the final partition. (If you were making separate partitions for /usr, /home, etc you could make more–however, we’re keeping it simple here.

Again, I’m asked to choose between logical and primary and choose logical. I’m asked for the first cylinder, with the default being the first unused one, which I accept by pressing enter–I’m then asked for the last cylinder, with the default being the last cylinder on the disk. Once again I press enter to accept it.

Lastly, I press

w

This writes the changes to disk–there are various warnings and messages. In most cases, you’re done. In others, you might be told that you have to reboot for the changes to take place.

references

man fdisk