November
29
Linux: Gentoo Cheat Sheet
By: B Macomber
cat /var/lib/portage/world
to show packages explicitly installed.
equery list *
to show all the installed packages, including dependencies.
less /usr/portage/profiles/use.desc
to view descriptions of the common USE flags.
nano /etc/portage/make.conf
to specify USE flags.
nano /etc/portage/package.use
to specify USE flags for individual packages.
emerge --sync
to get the latest Portage tree (metadata about packages), which is needed for all subsequent emerge commands.
eselect news read
to read news about Portage updates.
emerge -s package
to search for a package to see what exists.
emerge -S package
like above, except it will search all the descriptive text in addition to the package name. Note that Regular Expressions are used for this search. equery uses package
to see the effect of USE flags on the specified package (requires gentoolkit).
emerge -p package
to pretend to install a package, in order to show a preview of the dependencies, etc. that will be installed in total.
emerge -a package
like above, except it will ask to proceed after showing a preview of what will happen.
emerge -q package
to install quietly, omitting all the technical compilation output.
emerge -uD --with-bdeps=y @world -p
to update all packages explicitly installed, as well as their dependencies and their build dependencies, pretending at first.
emerge -uDN --with-bdeps=y @world -p
like above, except changes to USE flags will also be considered in determining what needs to be re-built.
etc-update
to resolve changes to config files made by Portage updates.
eread
to view Portage logs.
less /var/log/portage/elog/summary.log
ditto.
eselect
to choose which SLOT of a package to use (among other things).
gcc-config
to choose which version of C++ compiler to use.
env-update && source /etc/profile && emerge binutils glibc -1q
to rebuild the "toolchain" after changing which version of C++ compiler to use.
emerge -Ca package
to remove a package.
emerge -ca (--depclean --ask)
to remove unneeded dependencies.
emerge @preserved-rebuild
to rebuild packages using outdated libraries.
revdep-rebuild -p
to rebuild packages whose (dynamically linked) dependencies are no longer needed and have been removed (requires gentoolkit), pretending at first.
eclean -d -p distfiles
to delete leftover package installation/build files; destructive means to remove stuff except for packages explicitly installed, pretending at first.
rm /usr/portage/distfiles/*
to delete leftover package installation/build files, regardless of whether you might want them again.
eselect kernel
to choose a version of the kernel source.
cd /usr/src/linux && make menuconfig
to configure kernel.
cd /usr/src/linux && make oldconfig
to configure kernel, showing only options that have changed since the current .config file. Since this will only prompt you with a sequence of questions, you may want to run the above command at the same time in another terminal so that you can browse through the questions and gain some context of what's being asked.
make && make modules_install
to build kernel & modules.
mount /boot && cp arch/x86_64/boot/bzImage /boot/kernel-x.x.x-hardened && nano /etc/lilo.conf && lilo && umount /boot
to install kernel; change "x.x.x-hardened" to whatever version you're building.
rm -r /usr/src/linux-x.x.x-hardened && rm -r /lib/modules/x.x.x-hardened && rm /boot/kernel-x.x.x-hardened
to remove an old, obsolete kernel that's no longer acknowledged by Portage.
rc-config list
to show which services are started in which runlevels, including those inactive.
rc-update
to show which services are started in which runlevels, in a slightly different format.
rc-update add service runlevel
to add a service, such as apache2, to a runlevel, such as default, so that it gets started when the computer boots up.
rc-status
to show which services are currently running.
/etc/init.d/service restart
to restart a service. Besides restart, you can also start, stop, etc.
ntpq -p
to query the status of your Network Time Protocol Daemon.
nohup command > /dev/null 2>&1 &
to run a process in the background, squelching its output, continuing even after you log off.
echo 1 > /proc/sys/kernel/sysrq && echo b > /proc/sysrq-trigger
to remotely reboot without accessing any disks, when all else fails.
head -c 200 /dev/urandom | LC_CTYPE=C tr -c -d '[:alnum:]' | head -c 10
to generate a password of 10 alphanumeric characters.
By: B Macomber