Lesson 4 of 19 ↓
- 1.Fedora + Distrobox + Arch + AUR Setup Guide
- 2.Enabling Hibernate on Linux
- 3.A Practical Git Workflow
- 4.Useful Linux Commands & Tips
- 5.Mirroring Your Android Screen with Scrcpy
- 6.Downloading Media with Yt-dlp
- 7.Consistent C/c++ Style with Clang-format
- 8.Auto-mounting Drives at Boot
- 9.Customizing Grub
- 10.Linux Swap Files Explained
- 11.Zram: Compressed Swap in Ram
- 12.Custom App Launch Behavior Via .desktop Files
- 13.Custom Mime Icons in Gnome
- 14.Fixing Missing Dock Icons (startupwmclass)
- 15.Installing Questasim for Hdl Simulation
- 16.Building Python 2 From Source
- 17.Auto-Starting WhatsApp and Telegram (Minimized or Tray)
- 18.Custom Neovim Configuration Guide
- 19.Running Windows Applications on Linux Seamlessly with WinBoat (Docker)
2 min read
Useful Linux Commands & Tips
A running collection of small, easy-to-forget commands that come up often enough on a day-to-day Linux desktop to be worth keeping in one place — Bluetooth resets, GPU switching, bulk find-and-replace, and disabling core dumps.
Bluetooth Acting Up
sudo systemctl restart bluetoothDownloading a Playlist with Yt-dlp
yt-dlp -f 137+140 "Playlist Link"
# or, a more portable format selector:
yt-dlp -f "bv*+ba/b" -o "%(title)s.%(ext)s" "Playlist Link"
# keep yt-dlp itself up to date
sudo yt-dlp -UExtracting a .rar Archive
unrar x -o+ "Folder.rar" "Folder/"Force-killing an Unresponsive Program
sudo xkillClick the offending window and it's gone — faster than hunting for the PID with ps/kill when a GUI app is frozen.
Python Virtual Environments
python3 -m venv my_env
source my_env/bin/activateHybrid Gpu (optimus) Laptops
Force a program onto the discrete NVIDIA GPU:
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia <program>Switch the system-wide default GPU:
sudo prime-select intel
sudo prime-select nvidiaFormatting C/c++ with Clang-format
clang-format -i -style="{BasedOnStyle: Microsoft, IndentWidth: 2, TabWidth: 2, UseTab: Never}" testing.cHolding/unholding Nvidia Packages
Useful when an update needs to skip NVIDIA temporarily (see the update-automation lesson, which does exactly this):
sudo apt-mark hold nvidia-driver-* nvidia-dkms-* nvidia-kernel-* libnvidia-*
sudo apt-mark unhold nvidia-driver-* nvidia-dkms-* nvidia-kernel-* libnvidia-*
sudo apt upgradeChanging the Default Terminal Emulator
sudo update-alternatives --config x-terminal-emulatorBulk Find-and-replace Across Files
find . -type f -exec sed -i 's/oldword/newword/g' {} +Restricted to a specific extension:
find . -type f -name "*.txt" -exec sed -i 's/oldword/newword/g' {} +Printing the Duration of a Batch of Video Files
for file in "session-1.mkv" "session-2.mkv" "session-3.mkv"; do
echo -n "$file: "
ffprobe -v quiet -show_entries format=duration -of csv="p=0" "$file" | \
awk '{printf "%02d:%02d:%02d\n",$1/3600,($1%3600)/60,$1%60}'
doneForcing Dark Mode for a Single Program
GTK_THEME=Adwaita:dark programLaptop Battery Conservation Mode (lenovo/ideapad)
# enable
echo 1 | sudo tee /sys/bus/platform/drivers/ideapad_acpi/*/conservation_mode
# disable
echo 0 | sudo tee /sys/bus/platform/drivers/ideapad_acpi/*/conservation_modeDisabling Core Dumps
Core dumps are useful for debugging a crash, but on a daily-driver machine they just eat disk space in /var/lib/systemd/coredump/. To disable them going forward:
sudo mkdir -p /etc/systemd/coredump.conf.d
printf '[Coredump]\nStorage=none\nProcessSizeMax=0\n' | sudo tee /etc/systemd/coredump.conf.d/99-disable.conf
sudo systemctl daemon-reloadTo clear out ones that already exist:
sudo rm -f /var/lib/systemd/coredump/*
Comments
Loading the discussion…