Gentoo

Also known as: Gentoo Linux

On this page 7

Gentoo (also Gentoo Linux) is a source-based Linux distribution in which the package manager normally compiles software from source code on the user’s machine according to locally chosen options. Among the fundamentals of Linux, it is the standard example of a distribution that trades installation speed for maximum configurability and transparency.

Gentoo follows a rolling release model, so there are no numbered major versions to upgrade between. Its central tool, Portage, reads build recipes called ebuilds and combines them with system-wide and per-package settings to produce binaries tailored to the hardware and the administrator’s preferences.

How Portage builds software from source

Portage builds software by resolving dependencies, downloading upstream source archives, applying patches and compiling them according to ebuild instructions and local configuration. The command-line front end is emerge, and the collection of ebuilds is the Gentoo repository, synchronized locally and historically called the Portage tree.

Each ebuild is a Bash script with standardized phases such as fetching, unpacking, configuring, compiling and installing. Portage first installs files into a temporary image directory and then merges them into the live system, recording every file so that packages can be cleanly removed or upgraded later.

Ebuilds carry keywords that describe their status on each architecture. A keyword such as amd64 marks a version as stable on that platform, while ~amd64 marks it as testing. Most systems run stable keywords and accept testing versions only for selected packages, which keeps the rolling system predictable while still allowing newer software where it is needed.

The table below lists the configuration elements that shape every build.

ElementLocationWhat it controls
make.conf/etc/portage/make.confCompiler flags, global USE flags, parallel jobs
USE flagsmake.conf and package.useOptional features and dependencies per package
Profile/etc/portage/make.profileBaseline defaults for a system type
package.accept_keywords/etc/portage/Use of testing versions for chosen packages
World file/var/lib/portage/worldPackages explicitly requested by the administrator
Key Portage configuration elements

USE flags and system customization

USE flags are named switches that enable or disable optional features of a package at build time, and they are Gentoo’s most distinctive concept. A flag such as wayland, pulseaudio or ssl decides whether support for that feature is compiled in, which in turn decides which dependencies are pulled in.

Flags can be set globally for the whole system or per package, and profiles provide sensible defaults for desktop, server or hardened systems. The result is a system that contains only the code paths the administrator actually wants, which reduces disk usage and can shrink the attack surface.

Gentoo also offers unusual freedom in core components. Administrators can choose OpenRC or systemd as the init system, the glibc or musl C library, and among several kernel source packages, including distribution kernels that are built and configured automatically.

The following table shows common profile families and their typical use.

Profile familyTypical useNotable defaults
Default (base)Minimal servers and custom buildsFew USE flags enabled
DesktopWorkstations with a graphical sessionAudio, graphics and desktop flags
HardenedSecurity-sensitive systemsStack protection and hardened toolchain
systemd variantsSystems standardized on systemdsystemd instead of OpenRC
musl variantsSmall or embedded environmentsmusl C library instead of glibc
Common profile families

Gentoo compared with other distributions

Gentoo differs from most distributions because its default unit of delivery is source code, not a prebuilt binary package. Other distributions in the Linux fundamentals neighborhood make different trade-offs between control, effort and stability.

DistributionPackage formatRelease modelMain strength
GentooSource ebuilds, optional binariesRollingBuild-time customization
Arch LinuxBinary packages via pacmanRollingSimplicity and current software
DebianBinary .deb packagesFixed stable releasesStability and broad support
NixOSDeclarative Nix derivationsChannels and releasesReproducible configurations
SlackwareBinary tarballsFixed releasesMinimal, traditional design
Gentoo and related distributions

Gentoo has historically influenced other projects. ChromeOS and ChromiumOS use Portage as their build system, which shows that the tooling scales to producing reproducible images for large fleets of devices.

Installation and maintenance in practice

Gentoo is installed manually by following the Gentoo Handbook, which guides the user through partitioning, unpacking a stage 3 archive, configuring Portage, building a kernel and installing a bootloader. A stage 3 archive is a minimal prebuilt base system from which everything else is compiled.

Routine maintenance means syncing the repository and updating the world set, usually with emerge --sync followed by emerge -avuDN @world. Since late 2023, the project also provides official binary package hosts for common architectures, so many packages can be installed precompiled while others are still built locally.

The decision table below summarizes when Gentoo is a sensible choice.

SituationRecommendationReason
Learning how Linux is assembledGentoo is well suitedEvery layer is configured explicitly
Specialized or embedded hardwareGentoo or a custom buildFine control over features and toolchain
Production servers needing vendor supportChoose an enterprise distributionCertified support and fixed lifecycles
Laptop with limited time for upkeepUse binary packages or another distributionCompiling large software is slow
When Gentoo fits

Limitations and common misconceptions

The most persistent misconception is that Gentoo is dramatically faster because of compiler optimization. In practice, aggressive CFLAGS usually bring small or unmeasurable gains for typical workloads and can introduce hard-to-debug failures. The real benefits are feature selection, transparency and control.

  • Long build times: large packages such as web browsers, compilers and office suites can take hours on modest hardware.
  • Maintenance discipline: infrequent updates make dependency conflicts and news items easy to miss, so regular updates are safer.
  • Configuration drift: many per-package USE flag changes make systems hard to reproduce without careful documentation.
  • Smaller user base than major binary distributions, so commercial software vendors rarely test against it.

A non-technical view

Most Linux systems are like buying furniture already assembled. Gentoo is more like getting the plans and the raw wood. You decide which drawers, handles and finishes you want, and the system builds each piece for you.

This takes longer and needs more care. In return, you get exactly what you asked for and know how it was made. People choose it to learn, to control every detail, or to fit unusual hardware.

A concrete example

A small company builds network appliances on low-power x86 boards with 4 GB of memory. The engineers maintain a Gentoo build host that compiles all packages with a hardened profile and a minimal set of USE flags, removing graphical libraries, printing support and unused protocols.

The build host publishes binary packages for the whole fleet, so individual appliances never compile anything themselves. The final image is under 600 MB, contains only the required services, and each security update is rebuilt once centrally and rolled out to every device within a day.