Skip to content

k4my4b/Arch-Linux-Tips-And-Tricks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 

Repository files navigation

A collection of handy-dandy tips, tricks and How-to(s)

Pacman/package management related stuff

  • searching, installing, unstalling, updating and upgrading with pacman

    # To install
    sudo pacman -S
    
    # To uninstall
    # NOTE (-d skip dependency version checks (-dd to skip all checks))
    sudo pacman -Runcs
    
    # To refresh/update package database
    sudo pacman -Sy
    
    # To upgrade
    # NOTE (-yy to force a refresh even if up to date)
    # NOTE (-uu enables downgrades)
    sudo pacman -Syu
    
    # To search remotely
    # NOTE (-q show less information for query and search)
    pacman -Ss
    
    # To search locally
    # NOTE (-q show less information for query and search)
    pacman -Qs
    
    # To search for a package that provides X.
    pacman -F <X>
    
    # To view remote package info
    # NOTE (-ii for extended information)
    pacman -Si
    
    # To view installed package info
    # NOTE (-ii for extended information)
    pacman -Qi
    
    # To view packages installed by you
    pacman -Qe
    
    # To view packages installed as dependencies
    pacman -Qd
    
    # To clean up uneeded/orphaned packges
    sudo pacman -Runcs $(pacman -Qdtq)
  • pacman parallel downloading

    #ParallelDownloads = 5
    
    sudo sed -i 's/^#ParallelDownloads/ParallelDownloads/g' /etc/pacman.conf
  • pacman output colorization

    #Color
    
    sudo sed -i 's/^#Color/Color/g' /etc/pacman.conf
  • pacman easter egg (changes progress bar to a Pac-Man)

    #ILoveCandy
    
    sudo sed -i 's/VerbosePkgLists/VerbosePkgLists\nILoveCandy/g' /etc/pacman.conf
  • pacman verbose package change

    #VerbosePkgLists
    
    sudo sed -i 's/^#VerbosePkgLists/VerbosePkgLists\n/g' /etc/pacman.conf
  • (automatically) updating mirrors

    # install reflector first if not installed already
    sudo pacman -S --needed reflector
    
    # delete everything from the reflector service config file 
    # and replace them with only the following flags
    # /etc/xdg/reflector/reflector.conf
    --protocol https
    --sort score
    --save /etc/pacman.d/mirrorlist
    
    # enable the systemd timer to automatically update the mirrors every week
    sudo systemctl enable --now reflector.timer
  • adding a new key

    sudo pacman-key --recv-keys <key-id>
    pacman-key --finger <key-id> # shoudln't require root
    sudo pacman-key --lsign-key  <key-id>
    sudo pacman-key --refresh-keys
    
    # you can use the --keyserver flag to specify a keyserver
  • chaotic-aur (user maintained repo of pre-built popular AUR packages).

    # add chaotic-aur keys
    sudo pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com
    
    # sign said keys
    sudo pacman-key --lsign-key 3056513887B78AEB
    
    # install the keyring and chaotic mirrorlist packages so
    # they can be updated in the future
    sudo pacman -U 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-'{keyring,mirrorlist}'.pkg.tar.zst'
    
    # you will find the installed files under
    # /etc/pacman.d/chaotic-mirrorlist
    # /usr/share/pacman/keyrings/chaotic*
    # you must now add the repo to pacman.conf
    # as follow
    
    echo -e "\n[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist" | sudo tee -a /etc/pacman.conf
    
    # Refresh
    sudo pacman -Syy
  • command-not-found (suggest a package(s) containing the missing command)

    # update pacman files db
    sudo pacman -Fy
    
    # enable pacman files db weekly refresh
    sudo systemctl enable pacman-filesdb-refresh.timer
    
    # for `zsh` append to ~/.zshrc
    command_not_found_handler() {
      local pkg=$(pacman -Fq "$1")
    
      if [[ -z "$pkg" ]]; then
              printf "zsh: command not found: %s\n" "$1"
      else 
              printf  "\"%s\" may be found in the following package(s):\n\t%s\n" "$1" "$pkg"
      fi
    
      return 127
    }
    
    # for `bash` append to ~/.bashrc
    command_not_found_handle() {
      local pkg=$(pacman -Fq "$1")
    
      if [[ -z "$pkg" ]]; then
              printf "bash: command not found: %s\n" "$1"
      else 
              printf  "\"%s\" may be found in the following package(s):\n\t%s\n" "$1" "$pkg"
      fi
    
      return 127
    }
    

Useful packages to install

  • rng-tools (The rng-tools is a set of utilities related to random number generation in kernel)

    rng-tools is not needed anymore since Kernel 5.6 because /dev/random does not block anymore.

    # first check your entropy count
    cat /proc/sys/kernel/random/entropy_avail
    
    sudo pacman -S rng-tools opensc
    
    # enable service
    sudo systemctl enable --now rngd.service
    
    # verify your entropy count is higher
    cat /proc/sys/kernel/random/entropy_avail
  • Siera Breeze Enhanced AUR

    trizen -S --noedit kwin-decoration-sierra-breeze-enhanced-git
    
    # pre-built package available in chaotic-aur repo
  • Latte-dock AUR

    The development of latte-dock ceased back in Jul 2022, thus the project is officially dead.

    trizen -S --noedit latte-dock-git
    
    # pre-built package available in chaotic-aur repo
  • nerd-fonts ("patches developer targeted fonts with a high number of glyphs (icons). Specifically to add a high number of extra glyphs from popular ‘iconic fonts’ such as Font Awesome, Devicons, Octicons, and others.")

    sudo pacman -S --needed nerd-fonts
  • pkgfile (command-not-found).

    Pacman provides this functionality thus rendering this pakage redundant. See above for an alternative.

    In case you run a command that is not available on your system pkgfile hook will suggest a package that contains said command

    sudo pacman -S --needed pkgfile
    
    # as pkgfile maintains a seperate database it needs to be kept up-to-date
    sudo pkgfile -u
    
    # enable automatic pkgfile database updating
    sudo systemctl enable --now pkgfile-update.timer
    
    # for bash
    echo "source /usr/share/doc/pkgfile/command-not-found.bash" >> ~/.bashrc
    
    # for zsh
    echo "source /usr/share/doc/pkgfile/command-not-found.zsh" >> ~/.zshrc
  • irqbalance (spread out interrupts across all cores)

    This is may help with increased system throughput but will result in increased system latency and jitter

    sudo pacman -S --needed irqbalance
    
    # enable the systemd daemon
    sudo systemctl enable --now irqbalance.service
  • Ananicy AUR (community driven automatic process cpu/io priority assignment)

    trizen -S --noedit ananicy-cpp
    
    # enable the systemd daemon
    sudo systemctl enable --now ananicy.service
    
    # pre-built package available in chaotic-aur repo
  • kwin-lowlatency AUR (fork of kwin with major performance improvements)

    In the beginning of 2021, a massive change set has been merged to KWin which pretty much defeats the point of this project.

    trizen -S --noedit kwin-lowlatency
    
    # edit kwinrc located at ~/.config/kwinrc
    # and replace everything under compositing
    # as follow if the section doesn't exist
    # then simply append this to the file.
    -------------------------------------------------------
    [Compositing]
    LatencyControl=0
    MaxLatency=0
    MinLatency=0
    OpenGLIsUnsafe=false
    UnredirectFullscreen=false
    -------------------------------------------------------
    
    # pre-built package available in chaotic-aur repo
  • update-grub AUR (Simple wrapper around grub-mkconfig)

    trizen -S --noedit update-grub
    
    # pre-built package available in chaotic-aur repo

Drivers (Nvidia etc...)

  • Nvidia drivers

    # install the latest dkms module
    sudo pacman -S --needed nvidia-dkms
    
    # enable systemd nvidia services
    # DO NOT ISSUE WITH --now FLAG
    sudo systemctl enable nvidia-hibernate
    sudo systemctl enable nvidia-resume
    sudo systemctl enable nvidia-suspend
    
    # open mkinitcpio.conf with editor of your choice
    sudo vim /etc/mkinitcpio.conf
    
    # find "MODULES" and append the nvidia driver modules
    MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)
    
    # enable nvidia-drm by passing kernel parameter
    # for example in the case of grub open the grub
    # config file located at /etc/default/grub
    # and append nvidia-drm.modeset=1 to
    # GRUB_CMDLINE_LINUX_DEFAULT like so
    GRUB_CMDLINE_LINUX_DEFAULT=" ... nvidia-drm.modeset=1"
    
    # now rebuild the initramfs image and update grub
    sudo mkinitcpio -P && sudo update-grub

Networking

  • Enable (basic) networking via systemd

    # this will automatically manage interfaces
    sudo systemctl enable --now systemd-networkd
    
    # systemd equivalent for dhclient
    sudo systemctl enable --now systemd-resolved
    
    # systemd equivalent for resolvconf
    sudo pacman -S --needed systemd-resolvconf
    
    # link systemd-resolvd controlled resolv.conf to
    # /etc/resolv.conf
    sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
    
    # to configure a new interface for networkd
    # we need to create a config file for it
    # under /etc/systemd/network/ as follow:
    sudo vim /etc/systemd/network/20-wired.network
    
    # add the following to it (make any neccessary changes):
    -------------------------------------------------------
    [Match]
    Type=ether #Name=, PermanentMACAddress=, Path=, Driver=
    
    [Network]
    DHCP=ipv4
    
    [DHCP]
    RouteMetric=10
    -------------------------------------------------------
    
    # TODO add instructions for Wi-Fi

Boot/Splash screen

  • Plymouth (Plymouth is an independant module desgined to be called during the boot process to provide a graphical boot screen.)

    pacman -S --needed plymouth
    
    # add plymouth hook to mkinitcpio.conf
    # open /etc/mkinitcpio.conf with the editor
    # of your choice and make the following changes
    # *NOTE* It must be added after base and udev
    HOOKS=(base udev plymouth ...)
    
    # enable boot splash screen by passing the "splash" parameter to
    # the kernel command line.
    # e.g. edit grub config (/etc/default/grub) as follows:
    -------------------------------------------------------
    GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet splash"
    -------------------------------------------------------
    
    # If your system boots too fast to show the splash screen
    # you can forcefully delay the process for N seconds
    sudo systemctl edit plymouth-quit.service
    -------------------------------------------------------
    [Service]
    ExecStartPre=/usr/bin/sleep 3
    -------------------------------------------------------
    
    # to set the change the plymouth theme
    # run the following command
    sudo plymouth-set-default-theme <theme-name> # (see --list for available themes)
    
    # you must also make sure the graphics driver is included
    # in the initramfs, refer to Drivers section
    # for doing this nvidia for example.
    # once everything is done go ahead and rebuild the
    # initramfs and update grub
    # *NOTE* everytime you make a change to plymouth
    # e.g. change the theme initramfs needs to be rebuilt
    sudo mkinitcpio -P && sudo update-grub

kernel parameters are usually passed in via the bootloader e.g. grub. If you are using dracut kernel parameters can be built into the initramfs if you wish.
To view the current kernel parameters run cat /proc/cmdline

  • clocksource (used to set the default clock source.)
    Note: Certain early implmentaitons of HPET are buggy and the kernel will want to disable it, but if you are using a modern system e.g. AMD Ryzen you should, probably, be using HPET. Bare in mind clocksource seems to grealty affect the system throughput and latency and it would require a lot of testing to determine the proper extent of what these changes could mean for you (and their side effects).
    Note: Mesa Fixes A Large Performance Regression For Systems Using HPET. In order to force enable tsc on AMD systems you must add the following to your kernel cmdline tsc=reliable
    Note: To list available clocksources run cat /sys/devices/system/clocksource/**/available_clocksource
    Note: To verify run cat /sys/devices/system/clocksource/**/current_clocksource

    clocksource=hpet # tsc (timestamp counter register)
                     # hpet
                     # acpi_pm
                     # jiffies (DO NOT USE THIS OR ELSE ...)
  • skew_tick ("Offset the periodic timer tick per cpu to mitigate xtime_lock contention")
    Note: This can help with reducing system latency (on larger systems) at the cost of increased power consumption.

    skew_tick=1 # enable
              0 # disable
  • intel_pstate (intel specific cpu frequency scaling driver).
    Note: the pstate driver (at least for now) suffers from poor performance e.g. stuttering. It is best to either disable it completely and fallback to acpi driver if you have customised your cpu frequency e.g. overclocked, or set it to passive to bypass the driver's built-in governor but keep boost clocks.
    Note: To verify run cat /sys/devices/system/cpu/**/cpufreq/scaling_driver

    intel_pstate=no_hwp #recommended
                 disable
                 passive
  • amd_pstate (AMD scaling driver for the supported processors).
    Note: To verify run cat /sys/devices/system/cpu/**/cpufreq/scaling_driver

    amd_pstate=guided #recommended
               active
               passive
               disable
  • console_msg_format (Change console messages format)

    console_msg_format=syslog #recommended
                       default
  • cpufreq.default_governor (set the default cpu governor)

    cpufreq.default_governor=schedutil #recommended
                             powersave
                             performance
                             userspace
                             ondemand
                             conservative
  • lsm (Linux Security Modules)
    Note: To verify/check the current LSM list run cat /sys/kernel/security/lsm

    lsm=capability,landlock,lockdown,yama,apparmor,bpf # this will enable apparmor you will also need to install the apprmor package for userspace utils
  • iommu (Set IOMMU mode)

    iommu=pt # sets iommu mode to pass-through
    
    # see docs for more options
  • intel_iommu (Intel IOMMU driver options)
    Note: Intel IOMMU is off by default on most (if not all) Intel platforms

    intel_iommu=on
                off 
    
    # see docs for more options
  • amd_iommu (AMD IOMMU driver options)
    Note: AMD iommu mode is enabled by default

    amd_iommu=off
              force_enable # Force enable the IOMMU on platforms known to be buggy with IOMMU enabled.
    
    # see docs for more options