Chuleta de Gentoo
emerge — configuration — ebuild repository — dispatch-conf
world file — USE flags — ebuilds — profiles
upgrades — using testing packages — binary packages
tools — gentoolkit — eselect
Portage FAQ — cheat sheet — FAQ
all articles
Esto es un recopilatorio de comandos y consejos útiles a la hora de administrar sistemas Gentoo. Tanto principiantes como veteranos son animados a añadir sus consejos útiles más abajo.
Gestión de paquetes
Métodos de sincronización
Es importante leer y seguir todas las entradas de las noticias que puedan ser listadas tras la sincronización de un repositorio. Vea instrucciones detalladas sobre la actualización de paquetes.
Portage
Sincronice todos los repositorios que están configurados para autosincronizarse, incluyendo el repositorio ebuild principal de Gentoo:
root #
emaint --auto sync
O, para acortar:
root #
emaint -a sync
Sincronice el repositorio ebuild de Gentoo usando los espejos (mirrors) obteniendo una instantánea que tiene, como mucho, un día de antigüedad:
root #
emerge-webrsync
emerge --sync ahora ejecuta el módulo emaint sync con la opción --auto
. Vea operación de sincronización de Portage.
eix
Sincronice los repositorios de paquetes configurados y el repositorio ebuild Gentoo usando eix:
root #
eix-sync
Esto no solo sincroniza los repositorios, sino que también actualiza el caché usado por eix para realizar peticiones. Puede ser preferible configurar Portage para actualizar el caché automáticamente.
Listado de paquetes
qlist
Liste los paquetes instalados con su número de versión y el nombre del overlay usado:
root #
qlist -IRv
qlist es parte de app-portage/portage-utils.
eix
Para ver la lista de paquetes en el conjunto world, junto con sus versiones disponibles, es posible usar eix:
root #
eix --world | less
Para mantener el color en el texto mostrado, use la opción --color
:
root #
eix --color -c --world | less -R
Portage
Referenciando Package sets, los conjuntos de paquetes seleccionados son listados al ejecutar:
user $
emerge --pretend --quiet --emptytree --nodeps @selected
Liste los paquetes por nombre o todos (usando *) que usan múltiples ranuras:
user $
equery list --duplicates '*'
Package installation
En los ejemplos a continuación se usará el paquete www-client/firefox, pero los/las usuarios/as deberán reemplazarlo con el paquete que quieran instalar.
Liste qué paquetes serán instalados, sin instalarlos:
user $
emerge --pretend --verbose www-client/firefox
O, para acortar:
user $
emerge -pv www-client/firefox
Liste que paquetes serán instalados esperando confirmación antes de instalarlos:
root #
emerge --ask --verbose www-client/firefox
O, para acortar:
root #
emerge -av www-client/firefox
Instalar una versión específica
Install a specific version of a package (use "\=" (backslash and equal sign) for shells that attach special meaning to the "=" character). For example:
root #
emerge --ask =www-client/firefox-96.0.1
This will work temporarily, until the system is updated. During an update Portage will try to install the latest stable version of the package no matter which version is currently installed; whether the package was originally emerged via a preceding = operator or not.
To prevent Portage from automatically updating a package, add a line into a the /etc/portage/package.mask/package.mask 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:
/etc/portage/package.mask
<www-client/firefox-96.0.1
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:
root #
emerge --ask --oneshot www-client/firefox
Or, for short:
root #
emerge -a1 www-client/firefox
Package removal
See the emerge documentation on removing packages for full information.
--deselect
Use emerge --deselect (or -W
option for short) to remove the specified package from the @world set (i.e. it indicate that the package is no longer wanted):
root #
emerge --deselect www-client/firefox
Now run emerge --depclean (or -c
option for short). The --pretend
(-p
) option will have emerge display what actions would be taken, this must be reviewed to make sure no required packages would be removed:
user $
emerge --pretend --depclean
If emerge --depclean has not been run in a while, it may try to remove many packages - caution is advised. Once it has been assured that emerge --depclean will only remove unneeded packages, run:
root #
emerge --ask --depclean
The --ask
option is not really needed after a check via --pretend
, but is included in the previous example to help avoid "copy paste" mishaps.
Do not confuse the lower case
-c
switch, which is short for --depclean
(and is safe), with the upper case -C
switch which risks damaging the system and should only be used when absolutely required (see warning in following section).--depclean
To directly remove a package that no other packages depend on:
root #
emerge --ask --verbose --depclean www-client/firefox
Calculating 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 is sometimes necessary to first run:
root #
emerge --ask --verbose --update --newuse --deep @world
Use --changed-use
(-U
) in place of --newuse
(-N
) to avoid rebuilds when the only changes are USE flags added to or dropped from the repository. Use the --quiet
(-q
) flag for more succinct execution:
root #
emerge --ask --quiet --update --changed-use --deep @world
There is an
--unmerge
option (-C
), but this is not recommended and can break the system if not used with caution. This should only ever be used if necessary, and once properly informed of what it does. This will break the system, or other software, if used on some packages. The correct way to remove packages in Gentoo is virtually always with the --depclean
option, as described above. This may sometimes be useful to temporarily remove a hard block though.Package upgrades
Upgrade all packages in the world set, their dependencies (--deep
), and packages that have USE flag changes (avoiding unnecessary rebuilds when USE changes have no impact):
root #
emerge --ask --verbose --update --deep --changed-use @world
The --newuse
may be used in place of--changed-use
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 --with-bdeps=y
can be used to update build time dependencies also.
See upgrading Gentoo for more in depth information.
Package troubleshooting
Check for and rebuild missing libraries (not normally needed):
root #
revdep-rebuild -v
equery is part of app-portage/gentoolkit. Install it by issuing this command:
root #
emerge -a gentoolkit
Tell which installed package provides a command using equery:
user $
equery b `which vim`
qfile can provide a faster alternative to equery, if needed.
Tell which (not) installed package provides a command using e-file:
user $
e-file vim
Install e-file with:
root #
emerge -a app-portage/pfl
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
Do not unemerge sys-libs/glibc. It is needed by nearly every other package. If it gets inadvertently removed, a rescue stick/disk may be required. It may be possible to fetch glibc after setting
PORTAGE_BINHOST="http://packages.gentooexperimental.org/packages/amd64-stable/"
in /etc/portage/make.conf.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:
root #
emerge @module-rebuild
After upgrading to a new version of Go:
root #
emerge @golang-rebuild
For using new libraries:
root #
emerge @preserved-rebuild
Portage enhancements
Manage configuration changes after an emerge completes:
root #
dispatch-conf
After installations or updates
After updating perl-core packages:
root #
perl-cleaner --all
Or if previous didn't help:
root #
perl-cleaner --reallyall -- -av
For haskell packages:
root #
haskell-updater
USE flags
Obtain descriptions and usage of the USE flag X
using euse:
user $
euse -i X
Gather more information on euse by reading its manual page:
user $
man euse
Show what packages have the mysql
USE flag:
user $
equery hasuse mysql
Show what packages are currently built with the mysql
USE flag:
user $
eix --installed-with-use 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 -qt5' >> /etc/portage/package.use
Important Portage files
- /etc/portage - primary configuration directory for Portage.
- /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
- /etc/portage/profile/use.mask - for masking/unmasking locked use flags.
- /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 app-portage/genlop by issuing:
root #
emerge -a app-portage/genlop
Gather more information on genlop by reading its manual page:
root #
man genlop
View the last 10 emerges (installs):
root #
genlop -l | tail -n 10
View how long emerging LibreOffice took:
root #
genlop -t libreoffice
Estimate how long emerge -uND --with-bdeps=y @world will take:
root #
emerge -pU @world | genlop --pretend
Watch the latest merging ebuild during system upgrades:
root #
watch genlop -unc
Overlays
eselect repository
app-eselect/eselect-repository can be installed by issuing:
root #
emerge -a app-eselect/eselect-repository
List all existing overlays:
user $
eselect repository list
List all installed overlays:
user $
eselect repository list -i
See Eselect/Repository for more information.
Services
Obtain root shell (if the current user is listed in the sudoers list):
user $
sudo -i
OpenRC
Start the ssh daemon in the default runlevel at boot:
root #
rc-update add sshd default
Start the sshd service now:
root #
rc-service sshd start
Check if the sshd service is running:
root #
rc-service sshd status
Restart the sshd service:
root #
rc-service sshd restart
Stop the sshd service:
root #
rc-service sshd stop
List services, their status, and the runlevels they belong to:
root #
rc-status --all
Show enabled services and the runlevels they belong to (not whether they are running or not, just if they are enabled):
root #
rc-update show
systemd
Start the ssh daemon at boot:
root #
systemctl enable sshd
Start the sshd service now:
root #
systemctl start sshd
Check if the sshd service is running:
root #
systemctl status sshd
Tips
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.
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:
/etc/eixrc/00-eixrc
OVERLAY_CACHE_METHOD="assign"
Search packages in Portage by regular expressions
To search packages in Portage, along with installed version, by regular expressions:
root #
emerge -s "%^python$"
or
root #
emerge --search "%^python$"
qcheck
Use qcheck to verify installed packages:
root #
qcheck vim-core
qcheck comes with app-portage/portage-utils and can be installed by running this command:
root #
emerge -a app-portage/portage-utils
Learn more about qcheck by reading its manual page:
user $
man qcheck