This is the second part of the Gentoo Tutorials. In the first section “Minimal Gentoo Installation” we have built a fresh Gentoo system using the minimal install disk and downloading the stages/ports and building the kernel. This left us with a bare Gentoo OS. In this second Gentoo Tutorial we are going to customize and add different software to the system. To summarize the tasks:
Post-Install Configurations
Although our Gentoo installation is fully working, there are several things we should do to make it even better. First, lets setup our hostname, so that our system knows its name. To setup a hostname do the following:
pancho ~ # cd /etc
pancho etc # echo “127.0.0.1 pancho.darktech.org pancho localhost” > hosts
pancho etc # sed -i -e ’s/HOSTNAME.*/HOSTNAME=”pancho”/’ conf.d/hostnamepancho etc # hostname pancho
pancho etc # hostname -f
pancho.darktech.org
pancho etc #
As you can see above, my hostname is called pancho and I’m using the free DNS services of www.dtdns.com which includes the hostname darktech.org. So my full machine name (URL as well) is pancho.darktech.org
After setting the hostname it’s time to add a normal user to the system. So far we have done system wide tasks using the root username, but it isn’t really a good idea to be logged as root, unless you really need it. To add a new user, type the following in your command prompt:
pancho etc # adduser -g users -G lp,wheel,audio,cdrom,portage,cron -m val
where val is the actual username that we would like to add. The important thing here is that we have added val to the wheel group. This allows Val to su to root if necessary. Next – change the password for the newly created user:
pancho etc # passwd val
New UNIX password:
Retype new UNIX password:
passwd: password updated successfully
pancho etc #
In the next steps of this tutorial we will emerge several packages. Emerge is a very handy utility which helps you install different software by downloading, configuring and compiling it and at the same time will resolves its dependencies automatically for you. To ensure that emerge will download the packages from the nearest mirror we will install mirrorselect. To do so:
pancho etc # emerge -av mirrorselect
The -av options we have passed to emerge stands for –ask and –verbose. The –ask option will display what ebuilds and tbz2s will be installed, then ask whether to continue with the merge or abort. The –verbose option will display verbose text (i.e full information).
Once the mirrorselect is installed do the following:
pancho etc # mirrorselect -i -o >> /etc/make.conf
pancho etc # mirrorselect -i -r -o >> /etc/make.conf
Finally, we might want to tell emerge how many cpu’s we have on that machine. Usually it is okay to enter one more processor than you actually have. For example, if you have a single processor you can pass the -j2 option to the compiler which will simulate a second processor for you. To set that option:
pancho etc # echo ‘MAKEOPTS=”-j2″‘ >> /etc/make.conf
That’s it.. we have set everything we need in order to proceed and add some useful software.
Adding VIM package
Since the default Gentoo installation comes with nano/pico editor, which in my opinion is just not good enough to suit my needs (plus I’m simply used to vi) we will now install VIM. As usual we are doing the installation using emerge:
pancho etc # emerge -av vim
VIM has several dependencies which should be satisfied first. You will notice that emerge knows it and will do that automatically for us. In total the downloaded size should be around 10MB in size, which means we are going to compile it for some time, so be patient :)
Once emerge finish with the install (hopefully without an error) there is one final step we have to take. For some reason the configuration file was not copied during the install. Copy the vimrc example configuration file to your /root/.vimrc and /home/val/.vimrc (replace val with your actual username):
pancho ~ # cp /usr/share/vim/vim71/vimrc_example.vim .vimrc
pancho ~ # cp /usr/share/vim/vim71/vimrc_example.vim /home/val/.vimrc
That’s it. We now have vi installed. You can go ahead and try it by editing any file you might want or just creating a new one. Soon however you will notice that vi is making backups of each edited file by making a copy of the file with the same name but with a ~ as a suffix. While this is supposed to be a ‘feature’, I do not really like it and would like it turned off. You might do so by editing the .vimrc conf we have just copied. The lines you should look at are:
if has(”vms”)
set nobackup ” do not keep a backup file, use versions instead
else
set backup ” keep a backup file
endif
Change the 4th line from “set backup” to “set no backup” and save the file. Here we are :) No more backups.
Install slocate utility
The next thing in our task list is to install the slocate utility, since Gentoo does not come with locate by default. To install it, use emerge:
pancho ~ # emerge -av slocate
The package is rather small and should compile quickly. Once installed you need to update its database first:
pancho ~ # updatedb
This might take a couple of minutes. As soon as it finishes you can search for files easily. Lets try it out now and search for the .vimrc file and see if it will find it:
pancho ~ # locate .vimrc
/home/val/.vimrc
/root/.vimrc
pancho ~ #
Great! It seems to be working :)
Installing Screenie
Screenie is an interface to the screen utility which can attach and detach screens easily in somehow visual way. It is a great option if you are running a very long process or installing a big application (such as Gnome for example, which can take up to 10 hours to install…). In such cases you should keep your console alive. Not anymore! With screenie you can attach and detach any console.
Installing it is easy, as usual:
emerge -av screenie
It is harder to find how to work with it though. I was unable to find any documentation about this app and had to look at its source code. At the end it turned to be pretty much easy(and default as well). What you would need to do is:
In the next part of Gentoo Tutorials we will install apache web server and configure it for maximum speed (i.e optimize it, that’s how they call it today).