From Gentoo Wiki
Jump to: navigation, search

This article contains some of the tricks I use have found interesting or useful. Most of them are command line tricks.


List packages that are installed from a certain overlay.
List installed packages and add the overlay after the atom (from the topic above).

user $find /var/db/pkg -name repository | awk '{"cat " $0 | getline rep; close("cat " $0); sub("/var/db/pkg/",""); sub(/\/repository$/,""); print "=" $0 "::" rep}'

Another method that is about as twice as fast in processing the data:
user $find /var/db/pkg -name repository -printf '%h::' -exec cat {} \; | sed 's|/var/db/pkg/||'

How to re-emerge all of a package's dependencies? - forum topic. Many interesting answers there.

Kernel related

Read config variable description.
user $find -O2 /usr/src/linux/ -type f -name 'Kconfig' -print0 | xargs -0 sed -n '/^config KVARIABLE/,/^config/p' | head -n -1
[2]... and replace KVARIABLE with the one you're looking for. Just do not include the CONFIG_ at the beginning.
I bet there's much room for improvement --Zucca (talk) 18:24, 16 April 2017 (UTC)


The percentage CPU has been idling since last boot.

Perl version
user $procup="$(cat /proc/uptime)"; perl -e "printf '%.3f',${procup##* }/$(nproc --all)/${procup%% *}*100"
bc version
user $procup="$(cat /proc/uptime)"; echo -e "scale=3\n${procup##* }/$(nproc --all)/${procup%% *}*100" | bc
When computer is sleeping it isn't idling.

systemd tricks

How many times the computer has been put to sleep since last boot.

root #journalctl --boot=0 | grep -c 'Reached target Sleep.$'
This command does not require root permissions if the user running the command has permission to read all journal logs.

wiki tricks

Convert clipboard content to "wiki formatted". Basically escapes = and |.

user $xclip -o -selection clipboard | sed -e 's/|/{{!}}/g' -e 's/=/{{=}}/g' -e 's/{{{{=}}}}/=/g' | xclip -i -selection clipboard

misc tricks

root #beep -f 659 -l 460 -n -f 784 -l 340 -n -f 659 -l 230 -n -f 659 -l 110 -n -f 880 -l 230 -n -f 659 -l 230 -n -f 587 -l 230 -n -f 659 -l 460 -n -f 988 -l 340 -n -f 659 -l 230 -n -f 659 -l 110 -n -f 1047-l 230 -n -f 988 -l 230 -n -f 784 -l 230 -n -f 659 -l 230 -n -f 988 -l 230 -n -f 1318 -l 230 -n -f 659 -l 110 -n -f 587 -l 230 -n -f 587 -l 110 -n -f 494 -l 230 -n -f 740 -l 230 -n -f 659 -l 460
[3]... To find out what does this do, you need a PC-speaker support of some kind.

Another one, but compressed:

root #beep $(gunzip -ck <(base64 -d <<< "


  1. Gentoo forums - post: 8056088, list installed packages with overlay they are installed from.
  2. Gentoo forums - post: 7976738, how to extract and display kernel config variable description. Taken and modified slightly.
  3. Linux Beep Music #2
  4. Reddit - r/linux - Does anyone have or know a source for beep scripts?