Gentoo Cheat Sheet
This is Article description::a reference card of useful commands for administrating Gentoo systems. Newcomers and grey beards alike are encouraged to add their helpful tips below.
Package management
Sync methods
Sync all repositories that are set to auto-sync including the Gentoo ebuild repository:
root #emaint -a syncSync the Gentoo ebuild repository using the mirrors by obtaining a snapshot that is (at most) a day old:
root #emerge-webrsyncSync custom package repository and the Gentoo ebuild repository using eix:
root #eix-syncIf there are overlays created by app-portage/layman, to sync them:
root #layman -Sapp-portage/layman can be installed by issuing:
root #emerge -a app-portage/laymanapp-portage/eix can be installed by issuing:
root #emerge -a app-portage/eixGather more information on eix by reading its manual:
user $man eixPackage listings
qlist is provided by app-portage/portage-utils
List installed packages with version number and name of used overlay:
root #qlist -IRvTo view the list of packages in the world set along with their available versions it is possible to use app-portage/eix
root #eix --world | lessYou can keep color in the output by calling it with the "color" switch:
root #eix --color -c --world | less -RPackage installation
In the following examples the www-client/firefox package will be used, but users can replace it with their package of interest.
List what packages would be installed without installing them:
root #emerge -pv www-client/firefoxInstall a specific version of a package (Use '\='(backslash and equal sign) if the current shell attaches special meaning to '=' in a command):
root #emerge =www-client/firefox-24.8.0Install a package without adding it to the world file:
root #emerge --oneshot www-client/firefoxor
root #emerge -1 www-client/firefoxPackage removal
Recommended method
The recommended way to remove a package is by using deselect. This removes it from the @world set (i.e. says the package is no longer wanted). To clean up the system afterwards, run depclean as given below.
root #emerge --deselect www-client/firefoxAnd then depclean afterwards (the -p should be removed if after running, it shows will not remove any needed packages):
root #emerge --depclean -vpSeparately, to remove a package that no other packages depend on:
root #emerge --ask --verbose --depclean www-client/firefoxCalculating dependencies... done!
>>> Calculating removal order...
>>> These are the packages that would be unmerged:
www-client/firefox
selected: 68.5.0
protected: none
omitted: none
All selected packages: =www-client/firefox-68.5.0
>>> 'Selected' packages are slated for removal.
>>> 'Protected' and 'omitted' packages will not be removed.
Would you like to unmerge these packages? [Yes/No]
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 --quiet @worldAvoid unnecessary rebuilds when USE flags only get added to or dropped from the repository and use the --quiet flag for quicker execution:
root #emerge --update --changed-use --deep --quiet @worldUnclean removal (ignoring dependencies)
Remove a package even if it is needed by other packages:
root #emerge -C www-client/firefoxUse with caution. The
-C option can break software. Best if used to temporarily remove to satisfy a hard block.Package upgrades
Upgrade all installed packages, dependencies, and deep dependencies that are outdated or have USE flag changes (avoiding unnecessary rebuilds when USE changes have no impact):
root #emerge --ask --verbose --update --deep --changed-use @worldPackage troubleshooting
Check for and rebuild missing libraries (not normally needed):
root #revdep-rebuild -vequery is part of app-portage/gentoolkit. You can obtain it by issuing this command:
root #emerge -a gentoolkitTell which installed package provides a command using equery:
user $equery b `which vim`Tell which (not) installed package provides a command using e-file:
user $e-file vimInstall e-file with:
root #emerge -a app-portage/pflTell which packages depend on a specific package (cat/pkg in the example) using equery:
user $equery d www-client/firefoxGet information about a package using eix:
root #eix www-client/firefoxDo not unemerge sys-libs/glibc. It is needed by nearly every other package. If you inadvertedly remove it you may need a rescue stick/disk. You can fetch glibc after setting
PORTAGE_BINHOST="http://packages.gentooexperimental.org/packages/amd64-stable/" in /etc/portage/make.conf.Portage enhancements
Manage configuration changes after an emerge completes:
root #dispatch-confOr alternatively:
root #etc-updateAfter installations or updates
After updating perl-core packages:
root #perl-cleaner --allor if previous didn't help:
root #perl-cleaner --reallyall -- -avFor haskell packages:
root #haskell-updaterUSE flags
Obtain descriptions and usage of the USE flag X using euse:
user $euse -i XGather more information on euse by reading its manual page:
user $man euseShow what packages have the mysql USE flag:
user $equery hasuse mysqlShow what packages are currently built with the mysql USE flag:
user $eix --installed-with-use mysqlShow 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 -qt5' >> /etc/portage/package.useImportant Portage files[i 1]
- /etc/portage/make.conf - Global settings (USE flags, compiler options).
- /etc/portage/package.use - USE flags of individual packages. Can also be a folder containing multiple files.
- /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 information for every installed package a set of files about the installation.
Log management
genlop
genlop is a Portage log processor, also estimating build times when emerging packages.
Install genlop by issuing:
root #emerge -a app-portage/genlopYou can gather more information on app-portage/genlop by reading its manual page:
root #man genlopView the last 10 emerges (installs):
root #genlop -l | tail -n 10View how long emerging LibreOffice took:
root #genlop -t libreofficeEstimate how long emerge -uND --with-bdeps=y @world will take:
root #emerge -pU @world | genlop --pretendWatch the latest merging ebuild during system upgrades:
root #watch genlop -uncOverlays
eselect repository
app-eselect/eselect-repository can be installed by issuing:
root #emerge -a app-eselect/eselect-repositoryList all existing overlays:
user $eselect repository listList all installed overlays:
user $eselect repository list -iSee also Eselect/Repository
Layman
app-portage/layman can be installed by issuing:
root #emerge -a app-portage/laymanList all existing overlays:
user $layman -LList all installed overlays:
user $layman -lSee also Layman
Services
Obtain root shell (if the current user is listed in the sudoers list):
user $sudo -iOpenRC
Start the ssh daemon in the default runlevel at boot:
root #rc-update add sshd defaultStart the sshd service now:
root #rc-service sshd startCheck if the sshd service is running:
root #rc-service sshd statussystemd
Start the ssh daemon at boot:
root #systemctl enable sshdStart the sshd service now:
root #systemctl start sshdCheck if the sshd service is running:
root #systemctl status sshdGentoo Monthly Newsletter (GMN)
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 --regenThis 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:
/etc/eixrc/00-eixrcOVERLAY_CACHE_METHOD="assign"
qcheck
Use qcheck to verify installed packages:
root #qcheck -e vim-coreqcheck comes with app-portage/portage-utils and can be installed by running this command:
root #emerge -a app-portage/portage-utilsLearn more about qcheck by reading its manual page:
user $man qcheckSee also
- ↑ /etc/portage