Here's an unstructured list of Linux commands, a cheat sheet if you will that I've collected over the past 3 years of using Linux. The list is in no particular order.

 


Mount NAS as NFS

sudo mount 192.168.178.203:/backup /nfs/NAS

Copy folder and all subfolders and show progress

sudo rsync -avh --progress /mnt/Random /media/rick/Backup

Backup home folder server

sudo rsync -aP --exclude-from=/var/tmp/ignorelist /home/$USER/ /mnt/server_backup/home_backup2025-10

Make image of disk and compress

sudo dd if=/dev/sdf1 conv=sync,noerror bs=1M status=progress | gzip -c | dd of=/home/rick/Documents/pics.gz sudo dd if=/dev/sdc of=/home/rick/serverimage.img conv=sync,noerror status=progress bs=1M


Gnome DE only - Do not show prompt countdown before shut down

gsettings set org.gnome.SessionManager logout-prompt false

Gnome DE only - Disable update notifications

sudo apt remove update-notifier update-notifier-common


Ubuntu/Debian/apt enabled distro automatic updates

sudo apt-get install unattended-upgrades sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

Uncomment Allowed-Origins updates beneath security

dpkg-reconfigure -plow unattended-upgrades

or

sudo nano /etc/apt/apt.conf.d/20auto-upgrades

Add:

APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1";


Redirect terminal output to a file

SomeCommand > SomeFile.txt

Or if you want to append data:

SomeCommand >> SomeFile.txt

If you want stderr as well use this:

SomeCommand &> SomeFile.txt

or this to append:

SomeCommand &>> SomeFile.txt

If you want to have both stderr and output displayed on the console and in a file use this:

SomeCommand 2>&1 | tee SomeFile.txt


List all files minus any extension

ls -1 | sed 's/\.[^.]*$//'


Update Home Assistant Docker container

docker pull ghcr.io/home-assistant/home-assistant:stable docker stop homeassistant docker rm homeassistant


Debian server Docker run command

sudo docker run -d \ --name homeassistant \ --restart=unless-stopped \ --privileged \ -e TZ=Europe/Amsterdam \ -v /home/rick/homeassistant:/config \ -v /run/dbus:/run/dbus:ro \ --network=host \ --device /dev/ttyACM0 \ ghcr.io/home-assistant/home-assistant:stable


Access Grub

  • UEFI: press escape key repeatedly

  • Legacy: press shift repeatedly

Then type normal at GRUB prompt and press shift or escape once soon after to successfully launch grub.


Apple Macbook Facetime Webcam

Install this PPA: https://launchpad.net/~greg-whiteley/+archive/ubuntu/facetimehd


Change Foobar snap settings

foobar2000.wine winecfg

Snap storage location

~/snap/

Snap list all available versions

snap info package-name

Snap install specific version

snap install package-name --channel=.../...


Set up NFS

Server side sudo apt install nfs-kernel-server sudo dnf install nfs-utils sudo systemctl enable --now nfs-server

Create directory to be shared:

sudo mkdir -p /media/nfs

Configure which directories get shared and who can access them:

sudo nano /etc/exports

Add:

/media/nfs 192.168.1.0/24(rw,sync,no_subtree_check)

Load the new config:

sudo exportfs -arv Client side sudo apt install nfs-common sudo dnf install nfs-utils sudo mount -t nfs4 192.168.1.110:/media/nfs /media/share

Always mount:

sudo nano /etc/fstab

Add:

192.168.1.110:/media/nfs /media/share nfs4 defaults,user,exec 0 0

Then:

sudo mount -a


Show system information

inxi -Fzxx

Show all (virtual) interfaces

ip addr

Remove virtual interface

sudo ip link delete enp5s0

Disable bluetooth service

sudo systemctl disable bluetooth.service


Wireguard

First configure port forwarding on router:

  • IP: 192.168.178.203

  • Port: 33333

  • Type: TCP/UDP

Change interface for forwarding:

sudo nano /etc/wireguard/wg0.conf

Change file on external IP change:

sudo nano /etc/wireguard/client.conf

WireGuard internet access:

sysctl -w net.ipv4.ip_forward=1 sysctl -w net.ipv6.conf.all.forwarding=1

Make persistent:

echo "net.ipv4.ip_forward=1" | sudo tee /etc/sysctl.d/99-wireguard.conf echo "net.ipv6.conf.all.forwarding=1" | sudo tee -a /etc/sysctl.d/99-wireguard.conf sudo sysctl --system iptables -t nat -A POSTROUTING -o "enp4s0" -j MASQUERADE ip6tables -t nat -A POSTROUTING -o "enp4s0" -j MASQUERADE iptables -A FORWARD -i wg0 -o "enp4s0" -j ACCEPT iptables -A FORWARD -i "enp4s0" -o wg0 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A INPUT -p udp --dport 33333 -j ACCEPT apt-get install -y iptables-persistent netfilter-persistent save

Configuring ipv6 forwarding:

sysctl -w net.ipv6.conf.all.forwarding=1 ip6tables -t nat -A POSTROUTING -o enp4s0 -j MASQUERADE


Stop low-level messages on console

sudo nano /etc/sysctl.conf

Uncomment this line:

kernel.printk = 3 4 1 3


To release and renew IP address

Use ip a to see interface name:

sudo dhclient -r <int> sudo dhclient <int>


Set interfaces to activated and setup DHCP or static IP

sudo nano /etc/network/interfaces

Add:

auto eth0 iface eth0 inet dhcp

or

auto eth0 iface eth0 inet static address 192.168.0.100 netmask 255.255.255.0 gateway 192.168.0.1 dns-nameservers 4.4.4.4 dns-nameservers 8.8.8.8

Bring up interface:

ifconfig enp0s3 up

Check interface state:

ip a sh dev enp0s3

Check default gateway:

ip route

Restart the networking service after changing settings:

sudo systemctl restart networking


Blacklist old AMD driver

sudo nano /etc/modprobe.d/blacklist.conf

Add:

blacklist radeon

Then:

sudo update-initramfs -u

or

sudo dracut --regenerate-all

See which GPU driver is in use:

sudo lshw -c video


ZFS

Import 12TB zfs disk:

sudo zpool import backup -f

Create Disk Image with gnome-disks to ZFS disk:

sudo gnome-disks

Check which point release of Debian is running:

cat /etc/debian_version

Resize file system to minimum size:

sudo resize2fs /dev/SERVER-vg/root -M

List logical volumes in LVM:

lvscan lvs

Expand LVM to all remaining free space:

lvextend –l +100%FREE [MOUNTPOINT]

Expand filesystem to all remaining space:

sudo resize2fs [MOUNTPOINT]


Show all disks

lsblk fdisk -l

Get UUID of disk:

blkid

or

ls -l /dev/disk/by-uuid/

Mount disk on boot:

mkdir /mnt/NAME sudo nano /etc/fstab

Add:

UUID=xyxy /mnt/server_backup ext4 defaults 0 0

Then:

reboot


Fix qemu/kvm VM fixed to 1 core

Replace XML config parts:

<hyperv> <relaxed state='on'/> <vapic state='on'/> <spinlocks state='on' retries='8191'/> <reset state='on'/> <vendor_id state='on' value='0123456789ab'/> <frequencies state='on'/> </hyperv> <cpu mode='host-passthrough' check='none' migratable='on'> <topology sockets='1' dies='1' cores='6' threads='2'/> <cache mode='passthrough'/> <feature policy='require' name='topoext'/> <feature policy='require' name='svm'/> </cpu> <clock offset='localtime'> <timer name='rtc' tickpolicy='catchup'/> <timer name='pit' tickpolicy='delay'/> <timer name='hpet' present='no'/> <timer name='hypervclock' present='yes'/> <timer name='tsc' present='yes' mode='native'/> </clock>


Reset GNOME, also for resetting GNOME theming for GNOME apps

dconf reset -f /org/gnome/

Set GNOME apps (notably Thunderbird) to use the 24H time format:

gsettings set org.gnome.desktop.interface clock-format '24h'


Copy wireguard to new system

apt install wireguard wireguard-tools iptables

Edit:

/etc/sysctl.conf

Uncomment the next line to enable packet forwarding for IPv4:

#net.ipv4.ip_forward=1

Then:

sysctl -p

Copy /etc/wireguard/

systemctl start wg-quick@wg0 systemctl enable wg-quick@wg0


Send files via ssh

sudo scp -r -v /source/ rick@192.168.178.203:/home/rick/


SSH host key is not trusted

Remove relevant lines from:

sudo nano /root/.ssh/known_hosts


Convert svg to png

sudo dnf install inkscape inkscape -w 10240 -h 10240 smiling-cat-face-with-open-mouth.svg -o output.png


Nginx delay on system boot and restart on failure

sudo systemctl edit nginx

Add:

[Service] ExecStartPre=/bin/sleep 10 Restart=on-failure RestartSec=5s


Convert Print queue file (PostScript) to PDF

Locate print queue files at /var/spool/cups

ps2pdf


Looking glass setup

First blacklist driver for other card:

sudo nano /etc/modprobe.d/blacklist.conf

Add:

blacklist radeon

Then:

sudo update-initramfs -u

or

sudo dracut --regenerate-all

First try to boot up the VM with the /dev/shm or /dev/kvmfr0 (on my system) device. It will undoubtedly fail as before.

But we can use audit2allow to generate a policy module, we can feed the audit log into audit2allow so it will generate a policy based on the denied operations:

sudo grep denied /var/log/audit/audit.log | audit2allow -M mypolicy

Then we can install the newly created policy module:

sudo semodule -i mypolicy.pp

The VM should boot up just fine now, even after a reboot. Running:

sudo getenforce

or Disable SELinux:

sudo setenforce 0

Permanently disable SELinux:

sudo nano /etc/selinux/config


Error: Bluetooth: hci0: BCM: firmware Patch file not found broadcom

journalctl -b -p3

Fix, replace with own firmware codename:

cd /lib/firmware/brcm && sudo wget https://github.com/winterheart/broadcom-bt-firmware/raw/refs/heads/master/brcm/BCM20702A1-0a5c-21e3.hcd


See system info including model

dmidecode


Garbled startup screen

Add nomodeset to GRUB


Boot from different kernel (Fedora)

sudo grubby --info=ALL sudo grubby --set-default-index=


Grub set Default boot entry

Edit /etc/default/grub file Set GRUB_DEFAULT to the desired entry

Update grub Ubuntu:

sudo update-grub

Update grub Fedora:

sudo grub2-mkconfig -o /etc/grub2.cfg


Check boot performance

systemd-analyze systemd-analyze blame


BTRFS file systems and power failure

Problem with log tree indicated by error like: btrfs failed to recover log tree

btrfs rescue zero-log /dev/<device_name>

DON'T DO THIS UNLESS YOU ARE DESPERATE

btrfs check --repair /dev/<device_name>


Hide specific files

Create a .hidden file Add files to hide


Debian APT repository sources location

/etc/apt/sources.list


Install the Ladspa TAP-plugins (Kdenlive)

sudo dnf install ladspa-tap-plugins


Demucs Music Source Separation

python3 -m pip install -U demucs python3 -m pip install soundfile python3 -m pip install diffq


Wipe disk with random writes - Erase disk - Delete all data from disk - Remove all data disk

sudo shred -v -n 1 /dev/sdc


Check Intel iGPU (integrated) usage

sudo apt-get install intel-gpu-tools sudo intel_gpu_top


Clean cache

rm -rf ~/.local/state/* rm -rf ~/.cache/*


Change modified date

touch -t YYYYMMDDhhmm filename


Add ll as a command alias

sudo nano ~/.bashrc

Add:

# Custom aliases alias l='ls -a' alias ll='ls -l' alias la='ls -la'


Timeshift CLI

sudo apt install timeshift sudo timeshift --create --comments "new backup" --tags D --snapshot-device /dev/sda1 sudo timeshift --restore /etc/timeshift/timeshift.json


Format disk with ext4 file system

sudo mkfs -t ext4 /dev/sdb1 lsblk -f


Capture from attached DV camera or deck

dvgrab -rewind -s 0 -f dv2 -opendml -showstatus


Steam game access winecfg or winetricks

protontricks gameid winecfg


Generate bin and cue files from physical CD

cdrdao read-cd --datafile IMAGE.bin --driver generic-mmc:0x20000 --device /dev/cdrom --read-raw IMAGE.toc toc2cue IMAGE.toc IMAGE.cue

Output disc bin and cue image to ISO and extract any music tracks:

bchunk -v -w IMAGE.bin IMAGE.cue track


Mount disc image including music tracks of .bin and .cue

cdemu https://copr.fedorainfracloud.org/coprs/rok/cdemu


Bchunk convert .bin/cue to .iso

https://github.com/extramaster/bchunk

sudo apt-get install bchunk bchunk -v /home/rick/AutobahnRaser2/IMAGE.img /home/rick/AutobahnRaser2/IMAGE.cue IMAGE


Compute bcrypt Hash

Install apache2-utils

htpasswd -bnBC 5 "" my_secret_password

"" is username but can be blank -B = compute cost from 4-17


Modify timestamp data

exiftool -FileCreateDate="YYYY:MM:DD HH:MM:SS" -FileModifyDate="YYYY:MM:DD HH:MM:SS" -Quicktime:CreateDate="YYYY:MM:DD HH:MM:SS" FILE.mp4

Look at timestamp data:

exiftool -time:all -G1 -a -s File.mp4


Nextcloud

When try to Test and verify email settings Send Email: AxiosError: Request failed with status code 400 Set admin account email address in personal info

Change config.php Docker:

sudo docker run -it --rm --volume nextcloud_aio_nextcloud:/var/www/html:rw alpine sh -c "apk add --no-cache nano && nano /var/www/html/config/config.php"

Do not copy example files to new users: Add in config.php:

'skeletondirectory' => '',

Docker execute command:

docker exec -it <DOCKER-ID> php occ <COMMAND>

Docker prune images, containers, networks and volumes:

docker system prune --volumes


Linux Mint Cinnamon LightDM turn on/off auto login

sudo nano /etc/lightdm/lightdm.conf

Add:

autologin-user=username autologin-user-timeout=0

or remove for no auto login


Convert msg email archive to eml

sudo apt install libemail-outlook-message-perl find ~/mails -type f -name "*.msg" -print0 | xargs -0 -I {} msgconvert --outfile "{}.eml" "{}" && find ~/mails -type f -name "*.msg.eml" -exec sh -c 'mv "$1" "${1%}"' _ {} \;


Pipewire record audio you hear to a flac file

pw-record -P '{ stream.capture.sink=true }' test.flac


Convert mkv to mp4 using ffmpeg

ffmpeg -i example.mkv -c copy example.mp4


Fedora recover default repositories

dnf install fedora-repos

Recover dnf/rpm backend for Discover:

sudo dnf install plasma-discover-packagekit


Ubuntu enable Open with Wine Windows Program Loader on Windows executable files

sudo apt install wine-binfmt

cp /usr/share/doc/wine/examples/wine.desktop $HOME/.local/share/applications/