A little bit about Gentoo Linux
In my opinion one of the most fascinating linux-based operating systems is Gentoo Linux.
Any respected Nerd should have managed to install and update Gentoo as well as try to solve on their own the various problems that arise during the previous two phases.
The main feature of this unique operating system is that it does not have executables ready to run the installation but the user must compile everything directly from the source code: from installing the kernel and the entire operating system to installing individual programs and installing updates.
This technical choice was made by its founder to allow the user to create a flexible system optimized for his own hardware. Customizing each package means installing programs that are best calibrated for your needs and hardware. Hence, the system is faster than any other. In fact, the name Gentoo comes from the name of a penguin that is very fast underwater.
The package management system in Gentoo is Portage. It allows you to set the CFLAGS and USE flags so that, during the compilation, the executables are produced according to your needs and allow you to indicate which feature of a certain software you want to include during the compilation.
These and other features must be set, before compiling, in the /etc/portage/make.conf file.
The following is an example of a simple make.conf file:
Another important feature in Gentoo is the profile. The profile is an integral part of every Gentoo system. Not only does it specify default values for USE, CFLAGS and other setting variables, but it places the system within a certain range of package versions.
The current profile can be displayed with the following command:
eselect profile list
To change profile and pass (for example) to number 5 the command will be:
eselect profile set 5
To install Gentoo from scratch there is the wiki made by the developers. Once inside you have to select the architecture of your hardware and follow the long instructions. The first time I installed Gentoo from scratch on my old and obsolete pc, among a multitude of problems I encountered, it took me 18 days to compile everything. The second time, on a new performing PC and without encountering any problems, it took me 1 day.
Without going too deeply into setting up all the features in Portage and the technical use of Gentoo (there would be a lot to write about and for this purpose there is their own wiki), in this brief (but hopefully useful) guide I will describe what are the basic commands to perform a standard system update.
Main commands to perform system update
emerge-webrsync
or
emerge --sync
This command is the first to do and allows you to update the Portage tree. As you already understand emerge is the command-line interface to Portage.
emerge --ask --update --deep --with-bdeps=y --newuse @world
This command updates the entire system including dependencies.
The – – ask option is useful because without it the update would run immediately without asking anything. With this option, instead, you can first see the programs that will be updated and if there are any unmet dependencies before giving the ok to perform the update.
If you have altered any USE FLAGS you can add the – – newuse option to make these new Uses effective.
Without the – – with-bdeps=y option, instead, build-time dependencies are updated only when a package requires a newer version of the dependency than the one installed.
emerge --ask --depclean
This command removes orphaned dependencies.
It is very important to do it with the – – ask option to check which packages it eliminates before completely eliminating them and, in case we don’t want it to delete a specific one, we have to also add the – – exclude=’package_name’ option to the command.
We can also tell Portage that a package should never be deleted by running the command:
emerge --noreplace package_name
revdep-rebuild
This command scans and rebuilds missing shared library dependencies. It is useful when an updated package modifies other packages that depend on it.
revdep-rebuild comes with the gentoolkit package, which must therefore be installed first:
emerge --ask gentoolkit
As you can see here, then, to install a single package just run emerge like this:
emerge --ask package_name
or simply:
emerge package_name
emerge @preserved-rebuild
It recompiles all applications tied to a package after it has been updated.
emerge @module-rebuild
It is useful for reinstalling external kernel modules.
emerge @live-rebuild
It is similar to the command above but only affects unofficial packages.
etc-update
Perform possible updates to the configuration files.
env-update
It automatically updates the environment settings.
source /etc/profile
It reinitializes environment variables after a package upgrade.
rc-update
This command updates the run-levels of init.
It is recommended to update the system at least once a month to avoid too long and problematic compilations. I personally do it 2/3 times a month.
In another article I explain how to update the kernel in Gentoo Linux.