Skip to content

Instantly share code, notes, and snippets.

@alexander-danilenko
Last active September 5, 2024 19:52
Show Gist options
  • Save alexander-danilenko/b17c53a0e6f370f58316831613e14c5a to your computer and use it in GitHub Desktop.
Save alexander-danilenko/b17c53a0e6f370f58316831613e14c5a to your computer and use it in GitHub Desktop.
Fedora Cheatsheet

Fedora CheatSheet


Packages

RPM Fusion provides software that the Fedora Project or Red Hat doesn't want to ship. That software is provided as precompiled RPMs for all current Fedora versions and current Red Hat Enterprise Linux or clones versions.

sudo dnf install -y \
  "https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm" \
  "https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm"

DNF

DNF Config

CONFIG_FILE="/etc/dnf/dnf.conf" && PARAMS=(
  "defaultyes=True" # Select Y by default.
) && for PARAM in ${PARAMS[@]}; do
  grep "^$PARAM" $CONFIG_FILE || echo $PARAM | sudo tee -a $CONFIG_FILE
done

DNF Packages

APPS=(
  https://downloads.1password.com/linux/rpm/stable/x86_64/1password-latest.rpm
  https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
  https://zoom.us/client/latest/zoom_x86_64.rpm
  https://download.teamviewer.com/download/linux/teamviewer.x86_64.rpm
  
  @development-tools # Build-essentials analog.
  conda              # Python-agnostic package manager
  python3-virtualenv # Tool to create isolated Python environments
  zeal               # Offline documentation viewer

  exfat-utils         # Utilities to create, check, label and dump exFAT file system 
  htop                # Terminal system monitor
  java-latest-openjdk # Jave development kit
  jq                  # Takes JSON input and retrieves data by query
  mc                  # Two panel terminal file manager
  neofetch            # Shows Linux System Information with Distribution Logo
  net-tools           # Base network tools
  stacer              # Cool CleanMyMac alternative
  timeshift           # Backup utility

  arj   # arj archiver
  lha   # lzh unarchiver
  unrar # rar unarchiver

  libreoffice
  libreoffice-langpack-{uk,ru}
  libreoffice-help-{uk,ru}

  libheif-{freeworld,tools} # Tools for reading and manipulating HEIF files

  clementine       # Audio/Radio/Podcasts player
  dia              # Diagram editor
  evolution        # Outlook alternative
  evolution-ews    # Evolution Exchange support
  ffmpeg           # Universal media transcoder tool
  flameshot        # Powerful and simple to use screenshot software
  foliate          # Simple and modern GTK eBook reader
  inkscape         # Vector image editor
  kiwix-desktop    # Offline Wikipedia downloader/viewer
  telegram-desktop # Best IM!
  transmission     # Torrent client
  vlc
) && sudo dnf install -y ${APPS[*]} 

Flatpak

Flatpak is a tool for managing applications and the runtimes they use. In the Flatpak model, applications can be built and distributed independently from the host system they are used on, and they are isolated from the host system ('sandboxed') to some degree, at runtime.

Add flathub remote:

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

Install apps:

curl https://raw.githubusercontent.com/alexander-danilenko/fedora-environment/main/config.yml | yq -rc '.apps.flatpak[]' | xargs flatpak install -y flathub

⚠️ NOTE: yq python package is required

Fix cursors:

flatpak --user override --filesystem=/home/$USER/.icons/:ro 
flatpak --user override --filesystem=/home/$USER/.local/share/:ro

As a Fedora user and system administrator, you can use these steps to install additional multimedia plugins that enable you to play various video and audio types.

sudo dnf update @multimedia --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin

Fedora ffmpeg-free works most of the time, but one will experience version missmatch from time to time. Switch to the rpmfusion provided ffmpeg build that is better supported. You will still need to follow the next section for additional codecs or plugins related to packages you might have installed.

sudo dnf swap ffmpeg-free ffmpeg --allowerasing

Drivers

nVidia

⚠️ NOTE: Install RPM Fusion first.

sudo dnf install akmod-nvidia

Terminal

Fish is a smart and user-friendly command line shell for Linux, macOS, and the rest of the family.

Install fish:

sudo apt install -y fish

Set it as default for current user:

chsh -s $(which fish) && sudo !!

Copy configs:

mkdir -p $HOME/.config/fish/ && \
curl -L# -o $HOME/.config/fish/config.fish https://raw.githubusercontent.com/alexander-danilenko/dotfiles/main/.config/fish/config.fish && \
curl -L# -o $HOME/.config/fish/fish_variables https://raw.githubusercontent.com/alexander-danilenko/dotfiles/main/.config/fish/fish_variables

Oh My Fish: Package manager

Oh My Fish provides core infrastructure to allow you to install packages which extend or modify the look of your shell. It's fast, extensible and easy to use..

Install oh-my-fish:

curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish

Run fish and install plugins:

omf install (curl https://raw.githubusercontent.com/alexander-danilenko/fedora-environment/main/config.yml | yq -rc '.fish.packages[]')

Extend inotify

https://youtrack.jetbrains.com/articles/IDEA-A-2/Inotify-Watches-Limit

Inotify requires a "watch handle" to be set for each directory in the project. Unfortunately, the default limit of watch handles may not be enough for reasonably sized projects, and reaching the limit will force IntelliJ platform to fall back to recursive scans of directory trees.

To prevent this situation it is recommended to increase the watches limit (to, say, 512K)

grep '^fs.inotify.max_user_watches=524288' /etc/sysctl.conf || \
echo  'fs.inotify.max_user_watches=524288' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Development

Python

Python is an interpreted, interactive, object-oriented programming language that combines remarkable power with very clear syntax.

Install Python and its package manager

sudo dnf install python3 python3-pip python3-virtualenv pipenv

Install yq for parsing yml files format.

pip install yq

Install packages:

curl https://raw.githubusercontent.com/alexander-danilenko/fedora-environment/main/config.yml | yq -rc '.python3.pip3_global_packages[]' | xargs pip install

Node.JS

NVM allows you to quickly install and use different versions of node via the command line.

Install NVM:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.0/install.sh | bash

Install LTS and set as default:

nvm install --lts && nvm alias default "lts/*"

Install global packages:

curl https://raw.githubusercontent.com/alexander-danilenko/fedora-environment/main/config.yml | yq '.node.npm_global_packages[]' -cr | xargs npm install --global

⚠️ NOTE: yq python package is required

PHP

sudo dnf install -y php-{common,cli,curl,gd,json,mbstring,mysqli,opcache,pdo,xml,zip}

Composer

mkdir -p $HOME/.composer && \
sudo curl -#fsSL https://getcomposer.org/composer-stable.phar -o /usr/local/bin/composer && \
sudo chmod 755 /usr/local/bin/composer && \
composer --version && \
composer global require drupal/coder squizlabs/php_codesniffer friendsofphp/php-cs-fixer && \
cp -rf \
  ~/.composer/vendor/drupal/coder/coder_sniffer/Drupal* \
  ~/.composer/vendor/squizlabs/php_codesniffer/src/Standards

JetBrains Toolbox

curl -Ls https://raw.githubusercontent.com/nagygergo/jetbrains-toolbox-install/master/jetbrains-toolbox.sh | bash

Visual Studio Code

Add rpm repo and install code package

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo' && \
sudo dnf check-update && sudo dnf install -y code && \
curl -L# -o $HOME/.config/Code/User/settings.json --create-dirs https://raw.githubusercontent.com/alexander-danilenko/dotfiles/main/.config/Code/User/settings.json

Install extensions

curl https://raw.githubusercontent.com/alexander-danilenko/fedora-environment/main/config.yml | yq .apps.visual_studio_code.extensions[] -cr | while read extension; do
    code --install-extension $extension --force
done

⚠️ NOTE: yq python package is required

Sublime Apps

sudo rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg && \
sudo dnf config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo && \
sudo dnf install -y sublime-text sublime-merge && \
curl -L# -o $HOME/.config/sublime-text-3/Packages/User/Preferences.sublime-settings --create-dirs https://raw.githubusercontent.com/alexander-danilenko/dotfiles/main/.config/sublime-text-3/Packages/User/Preferences.sublime-settings

Wireguard VPN

Server

Quick setup script: https://github.com/Nyr/wireguard-install

wget https://git.io/wireguard -O wireguard-install.sh && bash wireguard-install.sh

Client (Fedora)

  • Install prerequisites:
    sudo dnf install wireguard-tools
  • Copy config to /etc/wireguard/wg0.conf file
  • ! Make sure port from config is whitelisted in firewall: sudo ufw allow 58320/udp
  • Enable autostart: sudo systemctl enable wg-quick@wg0
  • Disable autostart: sudo systemctl disable wg-quick@wg0
  • Start: sudo systemctl start wg-quick@wg0
  • Stop: sudo systemctl stop wg-quick@wg0
  • Status: sudo systemctl status wg-quick@wg0
#!/usr/bin/env python3

import click
import subprocess

@click.command(help='Manages Wireguard VPN.')
@click.argument('action', type=click.Choice(['start', 'stop', 'enable', 'disable', 'status']))
@click.option('--config', help='Config name.', default='wg0')
def wireguard_manager(action, config):
    if action in ['start', 'stop', 'enable', 'disable', 'status']:
        subprocess.call(f'set -ex && sudo systemctl {action} wg-quick@{config}', shell=True)

if __name__ == '__main__':
    wireguard_manager()

Containerization

Docker

Make sure current release version added in: https://download.docker.com/linux/fedora/

sudo dnf remove -y docker-{client,client-latest,common,latest,latest-logrotate,logrotate,selinux,engine-selinux,engine} && \
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo && \
sudo dnf install -y docker-ce docker-compose && \
sudo usermod -aG docker $USER && \
sudo systemctl enable docker && \
sudo systemctl restart docker && \
newgrp docker

Docksal

bash <(curl -fsSL https://get.docksal.io)

Desktop

GTK Themes / Icons

APPS=(
  papirus-icon-theme
  materia-gtk-theme
  paper-icon-theme
  yaru-theme
  yaru-sound-theme
  yaru-icon-theme
  yaru-gtk3-theme
  yaru-sound-theme
  breeze-cursor-theme
) && sudo dnf install -y ${APPS[*]}

Google Fonts

List fonts available to install:

curl https://gwfh.mranftl.com/api/fonts | jq '.[].id' -cr | sort

Install needed fonts:

FONTS_DIR="$HOME/.fonts"
FONTS=(
  jetbrains-mono
  open-sans
  roboto
  roboto-mono
  roboto-slab
  ubuntu
  ubuntu-mono
) && \
mkdir -p $FONTS_DIR && \ 
for FONT in ${FONTS[@]}; do
  DOWNLOAD_URL="https://gwfh.mranftl.com/api/fonts/${FONT}?download=zip&formats=ttf"
  FILE_PATH="/tmp/$FONT-ttf.zip"
  curl "$DOWNLOAD_URL" -o "$FILE_PATH"
  unzip -o $FILE_PATH -d $FONTS_DIR
done

Update fonts cache (may take a while): sudo fc-cache -f -v

Gnome

Gnome Tweaks:

sudo dnf install -y gnome-tweaks gnome-extensions-app

Gnome Extensions

Name Description
Battery Percentage (for laptops) Show battery remaining power percentage at the top panel
Blyr Blur Effect to GNOME Shell UI elements
Compiz alike magic lamp effect Magic lamp effect for minimizing windows
Compiz windows effect Compiz wobbly windows effect
Dash to Dock This extension moves the dash out of the overview transforming it in a dock for an easier launching of applications and a faster switching between windows and desktops
Dash to Panel Moves the dash into the gnome main panel so that the application launchers and system tray are combined into a single panel, similar to that found in KDE Plasma and Windows 7+
Emoji Selector Provides a parametrable popup menu displaying most emojis, clicking on an emoji copies it to the clipboard
Hide Activities Button Hides the Activities button from the status bar
Notification Alert Whenever there is an unread notification (e.g. chat messages), blinks the message in the user's menu with a color chosen by the user
Sound Input & Output Device Chooser Shows a list of sound output and input devices (similar to gnome sound settings) in the status menu below the volume slider
Tray Icons: Reloaded Bring back Tray Icons to top panel, with additional features
User Themes Gnome Shell themes support
Wireless HID Shows the battery of the wireless keyboards, mice, and game controllers in percentages and colors

Tweaks

Alsamixer save configuration

Save alsamixer settings once set: this should save alsamixer configurations to /etc/asound.state which gets loaded every startup.

sudo alsactl store

User Dirs in Synology Drive

~/.config/user-dirs.dirs

XDG_DESKTOP_DIR="$HOME/SynologyDrive/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_TEMPLATES_DIR="$HOME/SynologyDrive/Templates"
XDG_PUBLICSHARE_DIR="$HOME/SynologyDrive/Public"
XDG_DOCUMENTS_DIR="$HOME/SynologyDrive/Documents"
XDG_MUSIC_DIR="$HOME/SynologyDrive/Media/Music"
XDG_PICTURES_DIR="$HOME/SynologyDrive/Media/Pictures"
XDG_VIDEOS_DIR="$HOME/SynologyDrive/Media/Videos"

NFS Shares

Create directories first:

sudo mkdir -p /mnt/NAS/{Homes,Media}

Add to /etc/fstab:

192.168.50.123:/volume1/homes     /mnt/NAS/Homes      nfs defaults 0 0
192.168.50.123:/volume1/Media     /mnt/NAS/Media      nfs defaults 0 0

SWAP

Set swap to x2 of current ram:

/etc/systemd/zram-generator.conf:

[zram0]
max-zram-size = none
zram-fraction = 2

Boot into last booted grub record

In /etc/default/grub

Set:

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

Then apply the grub updates to grub config:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Fix Flatpak Postman crash

cd ~/.var/app/com.getpostman.Postman/config/Postman/proxy && openssl req -subj '/C=US/CN=Postman Proxy' -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout postman-proxy-ca.key -out postman-proxy-ca.crt && cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment