Gentoo Cheat Sheet

From Gentoo Wiki
Jump to: navigation, search
This article is a stub. You can help Gentoo Wiki by expanding it.

This is a reference card of useful commands for administrating Gentoo.

Portage Package Management Tips

Portage Tree Sync Methods

Sync the Portage tree using the mirrors by fetching the latest differences:

root #emerge --sync

Sync the Portage tree using the mirrors by obtaining a Portage snapshot that is at most a day old:

root #emerge-webrsync

Sync local overlays and the Portage tree using eix.

root #eix-sync

app-portage/eix can be installed by issuing this command:

root #emerge -a eix

You can gather more information on eix by reading its manual:

user $man eix

Package Installation and Removal

In the following tips www-client/firefox will be used as an example, simply substitute the package of interest with FireFox to perform the actions on your package.

List what packages would be installed without installing them:

root #emerge -pv www-client/firefox

Install a specific version of a package:

root #emerge =www-client/firefox-24.8.0

Remove a package and the dependencies that no other packages depend on:

root #emerge -cav www-client/firefox

Remove a package but not its dependencies:

root #emerge -C www-client/firefox

Remove no longer needed packages:

root #emerge -av --depclean

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

root #emerge --update --newuse --deep @world

Package Upgrades

Upgrade all installed packages, dependencies, and deep dependencies that are outdated or have USE flag changes:

root #emerge -uDN --with-bdeps=y @world

Package Troubleshooting

Check for and rebuild missing libraries:

root #revdep-rebuild -v

equery is part of gentoolkit. You can obtain it by issuing this command:

root #emerge -a gentoolkit

Tell which installed package provides a command using equery:

user $equery b `which vim`

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

user $equery d www-client/firefox

Get information about a package using eix:

root #eix www-client/firefox

Portage Enhancements

A graphical user interface to use with the Portage tree:

root #porthole

Manage configuration changes after an emerge completes:

root #dispatch-conf

After Installations or Updates

Rebuilds packages that depend on an recently updated library:

root #revdep-rebuild

After updating perl-core packages:

root #perl-cleaner --all

After updating python core packages:

root #python-updater

USE Flag Tips

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

user $euse -i X

You can gather more information on the euse by reading its manual page:

user $man euse

Obtain a description of the png USE flag:

user $euse -i | grep png

Show what packages have mysql use flag option:

user $equery hasuse mysql

Show what use flags are available for a specific package:

user $equery uses <package-name>

Quickly add a required USE flag for a package install

root #echo 'dev-util/cmake -qt4' >> /etc/portage/package.use

Important Portage Files[1]

  • /etc/portage/make.conf: Global settings (USE flags, compiler options)
  • /etc/portage/package.use: USE flags of individual packages
  • /etc/portage/package.accept_keywords: Keyword individual packages; e.g. ~amd64, ~x86, or ∼arm
  • /etc/portage/package.license: Accepted licenses
  • /var/lib/portage/world: List of explicitly installed package atoms
  • /var/db/pkg: Contains for every installed package a set of files about the installation

Log Management Tips


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

Install genlop by issuing this command:

root #emerge -a app-portage/genlop

You can gather more information on app-portage/genlop by reading its manual page:

root #man genlop

View last 10 emerges (installs), run:

root #genlop -l | tail -n 10

View how long emerging OpenOffice took, run:

root #genlop -t openoffice

Estimate how much 'emerge -uND --with-bdeps=y @world' will take, run:

root #emerge -pU world | genlop --pretend

Have a console watching the latest merging ebuild during system upgrades, run:

root #watch genlop -unc

Typical Administration Tips

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

user $sudo -s

Start the ssh daemon in the default runlevel at boot:

root #rc-update add sshd default

Start the xdm service now:

root #rc-service xdm start

Check if the sshd service is running or not:

root #rc-status sshd

Tips From the Gentoo Monthly Newsletter

Search packages in Portage by regular expressions:

root #emerge -s "%^python$"

Overlays 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.

root #emerge --regen

This trick also works in conjunction with eix. eix-update can use metadata cache generated by emerge –-regen to speed up things. To enable this, add the following variable to /etc/eixrc/00-eixrc:

FILE /etc/eixrc/00-eixrc

Use qcheck to verify installed packages:

root #qcheck -e vim-core

qcheck comes with app-portage/portage-utils and can be installed by running this command:

root #emerge -a app-portage/portage-utils

You can learn more about qcheck by reading its manual page:

user $man qcheck

External Resources