Gentoo Cheat Sheet

This is Article description::a reference card of useful commands and tips for administrating Gentoo systems. Newcomers and grey beards alike are encouraged to add their helpful tips below.

Portage
Sync all repositories that are set to auto-sync including the Gentoo ebuild repository:

Or, for short:

Sync the Gentoo ebuild repository using the mirrors by obtaining a snapshot that is (at most) a day old:

now runs the emaint sync module with the  option. See Portage's sync operation.

eix
Sync configured package repositories and the Gentoo ebuild repository using eix:

This not only syncs the repositories, it also updates the cache used by eix to perform queries. It may be preferable to configure portage to update the cache automatically.

qlist
List installed packages with version number and name of overlay used:

qlist is provided by.

eix
To view the list of packages in the world set, along with their available versions, it is possible to use eix:

To keep color in the output, use the  switch:

Package installation
In the following examples the package will be used, but users should replace it with the package they want to install.

List what packages would be installed, without installing them:

Or, for short:

List what packages would be installed, ask for confirmation before installing them:

Or, for short:

Install a specific version
Install a specific version of a package (use "\=" (backslash and equal sign) for shells that attach special meaning to the "=" character). For example:

To prevent Portage from automatically updating a package, add a line into a the file (create the file if it does not exist). Specify using the greater than operator prefix if it is an older package than latest stable or lesser than operator  as a prefix if it is a newer one:

See /etc/portage/package.mask for more details on package masking.

Install without adding to the world file
Install a package without adding it to the world file:

Or, for short:

--deselect
Use (or   option for short) to remove the specified package from the @world set (i.e. it indicate that the package is no longer wanted):

Now run (or   option for short). The   option will have  display what actions would be taken, this must be reviewed to make sure no required packages would be removed:

If has not been run in a while, it may try to remove many packages - caution is advised. Once it has been assured that will only remove unneeded packages, run:

The  option is not really needed after a check via , but is included in the previous example to help avoid "copy paste" mishaps.

--depclean
To directly remove a package that no other packages depend on:

As a safety measure, depclean will not remove any packages unless all required dependencies have been resolved. As a consequence of this, it is sometimes necessary to first run:

Use   in place of    to avoid rebuilds when the only changes are USE flags added to or dropped from the repository. Use the   flag for more succinct execution:

Package upgrades
Upgrade all packages in the world set, their dependencies, and packages that have USE flag changes (avoiding unnecessary rebuilds when USE changes have no impact):

The  may be used in place of  to make sure that all package use flags reflect the current state of those in the Gentoo repository, though this will entail more rebuilds. The  can be used to update build time dependencies also.

Package troubleshooting
Check for and rebuild missing libraries (not normally needed):

is part of. Install it by issuing this command:

Tell which installed package provides a command using equery:

Tell which (not) installed package provides a command using e-file:

Install e-file with:

Tell which packages depend on a specific package (cat/pkg in the example) using equery:

Get information about a package using eix:

Rebuilds
Sometimes it's necessary to rebuild some packages for them to work properly. Here are some of the common rebuilds:

After installing a new kernel:

After upgrading to a new version of Go:

For using new libraries:

Portage enhancements
Manage configuration changes after an emerge completes:

After installations or updates
After updating perl-core packages:

Or if previous didn't help:

For haskell packages:

USE flags
Obtain descriptions and usage of the USE flag  using euse:

Gather more information on by reading its manual page:

Show what packages have the  USE flag:

Show what packages are currently built with the  USE flag:

Show what USE flags are available for a specific package:

Quickly add a required USE flag for a package install:

Important Portage files

 * - primary configuration directory for Portage.
 * - Global settings (USE flags, compiler options).
 * - USE flags of individual packages. Can also be a folder containing multiple files.
 * - Keyword individual packages; e.g., , or.
 * - Accepted licenses
 * - for masking/unmasking locked use flags.
 * - List of explicitly installed package atoms.
 * - Contains information for every installed package a set of files about the installation.

genlop
genlop is a Portage log processor, also estimating build times when emerging packages.

Install by issuing:

Gather more information on by reading its manual page:

View the last 10 emerges (installs):

View how long emerging LibreOffice took:

Estimate how long will take:

Watch the latest merging ebuild during system upgrades:

eselect repository
can be installed by issuing:

List all existing overlays:

List all installed overlays:

Services
Obtain root shell (if the current user is listed in the sudoers list):

OpenRC
Start the ssh daemon in the default runlevel at boot:

Start the sshd service now:

Check if the sshd service is running:

Restart the sshd service:

Stop the sshd service:

List services, their status, and the runlevels they belong to:

Show enabled services and the runlevels they belong to (not whether they are running or not, just if they are enabled):

systemd
Start the ssh daemon at boot:

Start the sshd service now:

Check if the sshd service is running:

Search packages in Portage by regular expressions
To search packages in Portage by regular expressions:

Generate metadata caches
Ebuild repositories vary from very small to very large in size. As a result they slow down the majority of Portage operations. That happens because overlays do not contain metadata caches. The cache is used to speed up searches and the building of dependency trees. A neat trick is to generate local metadata cache after syncing overlays.

This trick also works in conjunction with eix. can use metadata cache generated by to speed up things. To enable this, add the following variable to :

qcheck
Use to verify installed packages:

comes with and can be installed by running this command:

Learn more about by reading its manual page:

External resources

 * Original gentoo-cheat repository
 * Forum post about gentoo-cheat
 * Another Gentoo cheat sheet
 * Collection of Gentoo tips
 * Newbie cheat sheet