2.10 System utilities

Software management

To quickly find programs use eix (package app-portage/eix), which has its own database for faster search.

Example:

eix mozilla
eix -S browser

To display the list of all installed packages, enter:

qlist-I

The following command does the same, but it also shows versions:

qlist -Iv

To view the list of the installed packages with their versions and their USE flags, execute:

qlist -Uv

If you cannot find your program in the Portage tree, you can search for it in overlays. To do so, go over to http://gpo.zugaina.org. The overlay name will be on the right, in the bottom line of the search result.
Before you can install a program found on this site, you must add the overlay to your system by executing:

layman-a <overlay>

To view the list of all available overlays, type:

layman -L

Installations and removals

To add and remove programs, use emerge (sys-apps/portage). For instance:

emerge kde-base/kgoldrunner
emerge -C mc

In this example, the Kgoldrunner game was installed and the MC (Midnight Commander) file manager was removed from the system.

If the package you want to install is masked, the --autounmask option will help to unmask.
That's how:

emerge --autounmask =www-client/opera-11.10.2092

At the end of the list of packages to be installed, you will see the following instructions:

The following keyword changes are necessary to proceed:
#required by =www-client/opera-11.10.2092 (argument)
=www-client/opera-11.10.2092 ~amd64

Copy the text below "The following keyword changes are necessary to proceed:" to /etc/portage/package.keywords/custom (you may omit the comment).

echo "=www-client/opera-11.10.2092 ~amd64" >> /etc/portage/package.keywords/custom

The simplest method to confirm that you want to unmask the package, though, is to use dispatch-conf (see below).

Rebuild the broken dependencies

Violation of dependencies may occur when you modify the installed packages. To correct this, we recommend to run revdep-rebuild after updating or deleting any programs.

Example:

revdep-rebuild

Configure software

Whenever updating configurations, ._cfg0000_ _ is appended to the new files, by precaution. For some services it is important to replace the old configuration files with the new ones after update. Sometimes the old configuration files may prevent a program from launching; such is the case with initscripts, located in the /etc/init.d directory.

To rewrite the configuration files in good time use the dispatch-conf tool:

dispatch-conf

When launched, this tool will show differences between all new and current versions of the configuration files. Please note: if a configuration file has been modified by Calculate (the system will keep you informed), you should not interfere. Hit z to decline the changes. To replace the file with the new one press u.

Service management

To manage (add or remove) runlevel services use the rc-update script.

Examples:

# view all runlevel services
rc-update show
# launch numlock on the default runlevel
rc-update add numlock default
# not to launch numlock anymore
rc-update del numlock

To list the services that are running, enter:

rc-status --all

Package content

To get a list of the files contained in an installed package or to see which package a file belongs to, use
qlist and qfile (app-portage/portage-utils), respectively.

Example:

# listing files in app-portage/portage-utils
qlist -ae app-portage/portage-utils
# finding out what qfile belongs to
qfile qfile

The which tool (sys-apps/which) may also be of some use: it shows the path to the file.
Example:

which equery

Providing security

Regular updates are a most important security measure.
You can check for security updates through GLSA, with glsa-check (app-portage/gentoolkit).

To view packages that need to be updated enter:

glsa-check -p $(glsa-check -t all)

To update the vulnerable packages enter:

glsa-check -f $(glsa-check -t all)

It would be useful to check dependencies afterwards; please see above Rebuilding the broken dependencies.

Tips and tricks

Package dependencies

To get information about package dependencies, you can use qdepends (app-portage/portage-utils).

Example:

qdepends -Q python

Saving traffic

If you have limited or expensive bandwidth, you can save with getdelta. First you'll have to install it:

if your architecture is i686:

ACCEPT_KEYWORDS=~x86 emerge getdelta

if your architecture is x86_64:

ACCEPT_KEYWORDS=~amd64 emerge getdelta

Then add the following line to your /etc/make.conf:

FETCHCOMMAND="/usr/bin/getdelta.sh \${URI} \${DISTDIR}/\${FILE}" 

Further operations differ little from the usual installation procedure, but that source deltas will be downloaded, thus reducing the incoming traffic spent on updates.

Clean distfiles

After some time, you might end up finding yourself with many different package versions. To free some disk space, you can delete distfiles left from older versions of programs. eclean-dist (app-portage/gentoolkit) is used for that:

eclean-dist

Disk defragmentation

Modern filesystems used on Linux minimize disk fragmentation, that's why defragmentation tools are relatively not numerous.

With XFS for instance, you can use sys-fs/xfsdump for defragmentation and configuring.

To view the current fragmentation state of a disk, execute:

xfs_db -r -c frag /dev/sdaX

where X is the partition number.

To begin defragmentation:

xfs_fsr -v /dev/sdaX

Check the hard drive

To check the hard disk for a broken sector, use the badblocks utility:

badblocks -svn -o /sda_log.txt -b 4096 -c 256 -p 2 /dev/sda

Thank you!