Linux - kamack38/Essentials GitHub Wiki

Linux Cheatsheet

  • shred <file> overwrite some file with random content and delete it

Warning

This does not work on COW filesystems file BTRFS, ZFS and BCacheFS. COW can be disabled for a single file using chattr +C /dir/file

  • basename/dirname <path> get the basename/dirname of the path
  • journalctl -p 3 -xb show system errors and add e[x]planations for current [b]oot
  • sudoedit edit files as a super user using specified $EDITOR
  • sudo udevadm control --reload && sudo udevadm trigger reload udev rules
  • gpg-connect-agent reloadagent /bye reload gpg-agent
  • rsync -avu --delete "/home/user/from" "/home/user/to" sync two directories
  • git merge-file merged.txt empty.txt file2.txt - merge merged.txt and file2.txt

Filesystem

  • mount -o remount -a - remount [a]ll filesystems as defined in /etc/fstab

Archlinux

  • pacman -F <name> find which package provides a specified binary
  • pacman -Ql <name> list all files installed by a package
  • pacman -Rns (pacman -Qtdq) clean orphans
  • pacman -Rdd <name> remove a package without removing packages that require it
  • pacman -Sc clean cache
  • makepkg --printsrcinfo > .SRCINFO generate .SRCINFO for a package

ffmpeg

Extract audio from file

ffmpeg -i input_file -vn -f mp3 output_file

Add soft subtitles to the selected video file

ffmpeg -i video_file -i subtitles_file -c copy -c:s mov_text -metadata:s:s:1 language=eng output_file

yt-dlp

Download only audio

yt-dlp -x --audio-format mp3

Snapper

List configs

snapper list-configs

List snapshots for a config

sudo snapper -c <config> list

Undo changes

sudo snapper -v -c root undochange <snapshot id to restore from>..<current snapshot id>

Tip

Snapper (at least for me) automatically creates a snapshot of the current system with id 0.

Tricks

  • ctrl+z suspend current job (make a program run in a background)
  • fg bring most recently suspended or running background job to foreground
  • bear -- make generate compile_commands.json from a compile command

Pipewire

  • cat /proc/asound/cards list sound cards

Output to multiple sinks at once

pactl load-module module-combine-sink

And to enable permanently

~/.config/pipewire/pipewire-pulse.conf

context.exec = [
    { path = "pactl"  args = "load-module module-combine-sink" }
]

Restarting sound services

systemctl --user restart wireplumber pipewire pipewire-pulse

Dolphin

Fixing file search

chmod -R 700 ~/.local/share/baloo
balooctl6 disable
balooctl6 purge
balooctl6 enable
touch ~/.local/share/baloo/index

Fixing the "open with" prompt

sudo pacman -S archlinux-xdg-menu

# Set this globally
XDG_MENU_PREFIX=arch- kbuildsycoca6

Source

Android app development

The following packages are required:

android-sdk jdk17-openjdk android-sdk-platform-tools android-sdk-build-tools android-tools android-sdk-cmdline-tools-latest gradle android-studio android-platform android-emulator

If you're still having issues check the permissions on /opt/android-sdk and unset custom $ANDROID_HOME

Fixing permissions:

sudo groupadd android
sudo usermod -a -G android $(whoami)
sudo chown -R root:android /opt/android-sdk
sudo chmod -R g=u /opt/android-sdk

APK decompilation

paru -S jadx jadx-gui-desktop

Traffic inspection

paru -S httptoolkit-bin

Create an AVD with Pixel 8 and Triamisu x86_64 API 33 Android 13.0 (Google APIs) (worked for me the best). Then start httptoolkit and follow in-app instructions.

Gimp

Make Gimp look more like photoshop

Follow instrcutinons on Diolinux/PhotoGIMP

Markdown

Converting to PDF using pandoc and Latex

First install the requirements

pacman -S pandoc-cli texlive-latex texlive-basic texlive-latexrecommended texlive-fontsrecommended

And then compile it

pandoc file.md -o output.pdf

SystemD

Disable power button

Go to /etc/systemd/logind.conf and uncomment:

HandlePowerKey=ignore
PowerKeyIgnoreInhibited=yes

Reload manager configuration

sudo systemctl daemon-reload

# Or to reload user configuration
systemctl --user daemon-reload

GRUB

Commands

  • reboot
  • halt - shutdown

All commands

⚠️ **GitHub.com Fallback** ⚠️