Gentoo Linux
I tried Gentoo once, and I fell in love!
How, why, when? Gentooooooooowiiie :)
When I told a friend that I would like to try Gentoo, the year was then
2008 then the person said that I will go back to Debian because I
will get tired of compiling code and doing everything from scratch all the time.
That person was wrong ;)
For 20 years I have been part of the Gentoo Community and in this part
I have intended to post everything that I have created around gentoo
and also various contributions from myself Gentoo
Respect to everyone that has been sharing your knowledge during the years,
now im trying to give back what i've learned during the years :)
List what package files belong to
#!/bin/bash
# Author: wuseman@bugcrowdninja.com
# License: WTFPL <http://www.wtfpl.net/>
# Same as `equery b <bin_file>` but 98% faster
# `equery b ffprobe` = 12.912s
# `wbelongsto ffprobe = 0.078s
find_package() {
target_file="$1"
pkg_dirs=$(rg -l "$target_file" /var/db/pkg/*/*/CONTENTS)
for pkg_dir in $pkg_dirs; do
pkg_name=$(basename $(dirname "$pkg_dir"))
actual_path=$(rg "$target_file" "$pkg_dir" | awk '{print $2}' | grep -E "^(/usr/bin/|/bin/|/usr/sbin/|/sbin/)")
if [ -n "$actual_path" ]; then
echo -e " * Searching for \e[92m$target_file\e[0m ..."
echo -e "\e[92m\e[1m$pkg_name\e[0m (\e[97m\e[1m$actual_path\e[0m)"
return
fi
done
echo -e " * Searching for \e[92m$target_file\e[0m ..."
echo -e "\e[91m\e[1mFile does not belong to any package\e[0m"
}
export -f find_package
printf "%s\n" "$@" | xargs -P 4 -I {} bash -c 'find_package "$@"' _ {}
Check the running kernel configuration for strict /dev/mem restrictions:
To unlock this feature so we can read memory we must set above to n
Some kernels allow us to disable devmem protection from kernel commandline
Re-emerge all ebuilds with missing files
Print last time emerge was used
Modules short with description
Print current installed distro
View emerge log by date in humand friendly time
Preventing a specific package from being updated during @world upgrades
A near-perfect Gentoo upgrade workflow
# 1. Sync tree (fast + reliable)
eix-sync
# 2. Read important notices
eselect news read
# 3. Update local metadata indexes (optional but useful)
eix-update
# 4. Deep system upgrade
emerge --update --newuse --deep @world
# 5. Handle preserved libraries immediately
emerge @preserved-rebuild
# 6. Update configuration files
dispatch-conf
# 7. Rebuild broken reverse deps (only if needed)
revdep-rebuild
# 8. Clean up old packages
emerge --depclean
# 9. Rebuild after depclean if needed
revdep-rebuild
# 10. Clean distfiles safely
eclean-dist -d
Create an alias for above example of upgrading Gentoo Linux
Genkernel
Configure dropbear in initramfs
- Install net-misc/dropbear
- Create/Copy
authorized_keysfile to/etc/dropbear/authorized_keys
- Set SSH Enable in
/etc/genkernel.confor use--sshwith genkernel command
Include Firmware files in /etc/genkernel.conf
Print in percent of all available packages in tree we installed
For view bluetooth percentage in bluetoothctl and plasma-desktop tray icon
- Please use
upowerfor monitor bluetooth battery instead, you can find more info here: https://linux-shell.se/linux-shell/upower/
bluetoothctl info
Device 14:3F:A6:15:93:43 (public)
Name: WH-1000XM4
Alias: WH-1000XM4
Class: 0x00240404
Icon: audio-headset
Paired: yes
Bonded: yes
Trusted: yes
Blocked: no
Connected: yes
LegacyPairing: no
UUID: Vendor specific (00000000-deca-fade-deca)
UUID: Headset (00001108-0000-1000-8000)
UUID: Audio Sink (0000110b-0000-1000-8000)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000)
UUID: Advanced Audio Distribu.. (0000110d-0000-1000-8000)
UUID: A/V Remote Control (0000110e-0000-1000-8000)
UUID: Handsfree (0000111e-0000-1000-8000)
UUID: PnP Information (00001200-0000-1000-8000)
UUID: Vendor specific (81c2e72a-0591-443e-a1ff)
UUID: Vendor specific (8901dfa8-5c7e-4d8f-9f0c)
UUID: Vendor specific (931c7e8a-540f-4686-b798)
UUID: Vendor specific (96cc203e-5068-46ad-b32d)
UUID: Vendor specific (b9b213ce-eeab-49e4-8fd9)
UUID: Vendor specific (f8d1fbe4-7966-4334-8024)
Modalias: usb:v054Cp0D58d
Battery Percentage: 0x32 (50)
Enabling static-user for qemu-arm-static
Ensure that qemu is installed with the static-user flag to obtain the static component.
Mullvad Browser and Tor Browser requires
This will solve Couldn't load XPCOM. issues for tor browser
Video Editor
cat << "EOF" > /etc/portage/package.use/avidemux
media-libs/avidemux-plugins a52 aac alsa fontconfig gui lame libsamplerate nvenc opengl opus oss pulseaudio truetype twolame vdpau vorbis vpx x264 x265 xv xvidmedia-libs/avidemux-core nls nvenc sdl vaapi vdpau xc
media-video/avidemux gui nls opengl sdl vaapi vdpau xv
>=media-libs/avidemux-core-2.8.1-r1 vdpau vaapi nvenc
EOF
It's possible to do the same operations using the command line
Bindfmt for Qemu
:python3.11:M::\xa7\x0d\x0d\x0a::/usr/bin/python3.11:
:qemu-aarch64:M::\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/libexec/qemu-binfmt/aarch64-binfmt-P:OCPF
:qemu-alpha:M::\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/libexec/qemu-binfmt/alpha-binfmt-P:OCPF
:qemu-arm:M::\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/libexec/qemu-binfmt/arm-binfmt-P:OCPF
:qemu-armeb:M::\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/armeb-binfmt-P:OCPF
:qemu-cris:M::\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x4c\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/libexec/qemu-binfmt/cris-binfmt-P:OCPF
:qemu-hexagon:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xa4\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/libexec/qemu-binfmt/hexagon-binfmt-P:OCPF
:qemu-hppa:M::\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x0f:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/hppa-binfmt-P:OCPF
:qemu-loongarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02\x01:\xff\xff\xff\xff\xff\xff\xff\xfc\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/libexec/qemu-binfmt/loongarch64-binfmt-P:OCPF
:qemu-m68k:M::\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/m68k-binfmt-P:OCPF
:qemu-microblaze:M::\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xba\xab:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/microblaze-binfmt-P:OCPF
:qemu-mips64:M::\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/mips64-binfmt-P:OCPF
:qemu-mips64el:M::\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/libexec/qemu-binfmt/mips64el-binfmt-P:OCPF
:qemu-mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00:\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20:/usr/libexec/qemu-binfmt/mips-binfmt-P:OCPF
:qemu-mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00:\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00:/usr/libexec/qemu-binfmt/mipsel-binfmt-P:OCPF
:qemu-mipsn32:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20:\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20:/usr/libexec/qemu-binfmt/mipsn32-binfmt-P:OCPF
:qemu-mipsn32el:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00:\xff\xff\xff\xff\xff\xff\xff\x00\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00:/usr/libexec/qemu-binfmt/mipsn32el-binfmt-P:OCPF
:qemu-ppc64:M::\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/ppc64-binfmt-P:OCPF
:qemu-ppc64le:M::\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00:/usr/libexec/qemu-binfmt/ppc64le-binfmt-P:OCPF
:qemu-ppc:M::\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/ppc-binfmt-P:OCPF
:qemu-riscv32:M::\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/libexec/qemu-binfmt/riscv32-binfmt-P:OCPF
:qemu-riscv64:M::\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/libexec/qemu-binfmt/riscv64-binfmt-P:OCPF
:qemu-s390x:M::\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/s390x-binfmt-P:OCPF
:qemu-sh4:M::\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/libexec/qemu-binfmt/sh4-binfmt-P:OCPF
:qemu-sh4eb:M::\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/sh4eb-binfmt-P:OCPF
:qemu-sparc32plus:M::\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x12:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/sparc32plus-binfmt-P:OCPF
:qemu-sparc64:M::\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2b:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/sparc64-binfmt-P:OCPF
:qemu-sparc:M::\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/sparc-binfmt-P:OCPF
:qemu-xtensa:M::\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x5e\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/libexec/qemu-binfmt/xtensa-binfmt-P:OCPF
:qemu-xtensaeb:M::\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x5e:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/libexec/qemu-binfmt/xtensaeb-binfmt-P:OCPF
Genkernel Initramfs
Avoid showing the following decryption command at boot
Version-restricted package installation
Install an exact version of sys-kernel/gentoos-sources
| Operator | Meaning |
|---|---|
= |
Exactly this version |
~ |
Any revision of this version |
< |
Strictly lower than |
<= |
Lower than or equal |
> |
Strictly greater than |
>= |
Greater than or equal |
:* |
Any slot |
:slot |
Specific slot |
:= |
Slot-operator dependency |
Same version, any revision
-
Matches:
-
6.18.0
- 6.18.0-r1
- 6.18.0-r2
Mask a Specific Kernel Version (Prevent Upgrades)
Accept an Unstable Kernel Version on Stable Systems
Hide the encryption command at initramfs level using genkernel initramfs

Edit /usr/share/genkernel/defaults/initrd.scripts that holds the value on line number 1239
Now search for: Using the following decryption command: cryptsetup ....
Comment out the line: good_msg "Using the following decryption command: ${1}" ${CRYPT_SILENT} and replace it with:
good_msg Unknown cryptsetup method to unlock the device" ${CRYPT_SILENT} and we are ready to go, here is a screenshot
how it looks during boot now instead of the above and default one
Update the `good_msg´ to the following line, here is where you should find it and how it should looks for you
crypt_filter() {
local ask_pass=${2}
# good_msg "Using the following decryption command: ${1}" ${CRYPT_SILENT}
good_msg "Unknown cryptsetup method to unlock the device" ${CRYPT_SILENT}
if [ "${CRYPT_SILENT}" = '1' ]
then
eval run ${1}
elif [ "${PLYMOUTH}" = '1' ] && [ ${ask_pass} -eq 1 ]
then
local ply_cmd_file="$(mktemp -t 'ply_cmd.XXXXXX' 2>/dev/null)"
printf '#!/bin/sh\n%s\n' "${1}" > "${ply_cmd_file}"
run chmod 500 "${ply_cmd_file}"
plymouthRun ask-for-password --prompt "Enter LUKS passphrase" \
--number-of-tries=3 --command="${ply_cmd_file}"
res=$?
run rm "${ply_cmd_file}" >/dev/null 2>&1
return ${res}
else
splash 'verbose' >/dev/null &
eval run ${1}
res=$?
if [ ${res} -eq 0 ]
then
splash set_msg 'Disk unlocked.'
fi
return ${res}
fi
}

List what package files belong to
#!/bin/bash
#
#---------------------------------------------------
#
# Script Description
#
# Same as `equery b <bin_file>` but 98% faster
# `equery b ffprobe` = 12.912s
# `wbelongsto ffprobe = 0.078s
#
#---------------------------------------------------
find_package() {
target_file="$1"
pkg_dirs=$(rg -l "$target_file" /var/db/pkg/*/*/CONTENTS)
for pkg_dir in $pkg_dirs; do
pkg_name=$(basename $(dirname "$pkg_dir"))
actual_path=$(rg "$target_file" "$pkg_dir" | awk '{print $2}' | grep -E "^(/usr/bin/|/bin/|/usr/sbin/|/sbin/)")
if [ -n "$actual_path" ]; then
echo -e " * Searching for \e[92m$target_file\e[0m ..."
echo -e "\e[92m\e[1m$pkg_name\e[0m (\e[97m\e[1m$actual_path\e[0m)"
return
fi
done
echo -e " * Searching for \e[92m$target_file\e[0m ..."
echo -e "\e[91m\e[1mFile does not belong to any package\e[0m"
}
export -f find_package
printf "%s\n" "$@" | xargs -P 4 -I {} bash -c 'find_package "$@"' _ {}
SDDM Xsetup – Set Primary Display with xrandr
Resource(s)
- https://www.gentoo.org/
- https://www.gentoo.org/downloads/
- https://wiki.gentoo.org/wiki/Main_Page
- https://wiki.gentoo.org/wiki/User:Wuseman
- https://wiki.gentoo.org/wiki/Cmus
- https://wiki.gentoo.org/wiki/User:Wuseman/Templates
- https://wiki.gentoo.org/wiki/Android/adb
- https://wiki.gentoo.org/wiki/User:Wuseman/lftp
- https://wiki.gentoo.org/wiki/User:Wuseman/glFTPd
- https://wiki.gentoo.org/wiki/User:Wuseman/Cheatsheet
- https://devmanual.gentoo.org/eclass-reference/make.conf/index.html
Happy Hacking! :material-gentoo: :octicons-heart-fill-24: