A.K.A. Commands I keep forgetting no matter how many milions time I type them

Magic SysRq key commands

The magic SysRq key is a key combination understood by the Linux kernel, which allows the user to perform various low-level commands regardless of the system’s state.

ALT + SysRq key (usually Stamp) + ..

  • f to call oom_kill
Remove kernel module manually installed with make/dkms

If you get stuff like:

hid-nintendo.ko:
Running module version sanity check.
Module version  for hid-nintendo.ko
exactly matches what is already found in kernel 6.1.0-4-amd64.
DKMS will not replace this module.
You may override by specifying --force.
Error! Installation aborted.
Error! One or more modules failed to install during autoinstall.

during a kernel upgrade/reubild, and that module was not installed from a package:

dkms list
dkms remove <NAME/VERSION> --all

will clean it up. Re run apt upgrade to continue the kernel building.

miscellanea
  • usermod -aG sudo $USER add user to sudoers
  • exec su -l $USER Reload a Linux user’s group assignments without logging out
  • script record (and play) shell session
  • xclip -sel clip < TEXTFILE copy file to default clipboard
  • hdparm -S 240 /dev/sda hdd spindown time
  • /sys/class/backlight/intel_backlight/brightness or /sys/devices/platform/thinkpad_acpi/leds/tpacpi\:\:power/brightness thinkpad backlight PWM endpoint
  • rsync -avzP user@host:$SOURCE user@host:$DEST
  • curl -d '{"MyKey":"My Value"}' -H "Content-Type: application/json" $ENDPOINT:$PORT/ curl JSON
  • curl -d @payload.json -H "Content-Type: application/json" $ENDPOINT:$PORT/ curl JSON file
  • nmcli dev wifi con "$SSID" password "$PASSPHRASE"
  • ssh -L $REMOTEPORT:localhost:$LOCALPORT $USER@$REMOTEHOST SSH loopback a.k.a. $REMOTEHOST:$REMOTEPORT is available at localhost:$LOCALPORT ssh tunneled/encrypted
  • GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'kaf500!'; MySQL, init wp tables
  • hostnamectl
  • visudo and append $USER ALL=(ALL) NOPASSWD: ALL
  • ffmpeg -i input.mp4 output.mp4 -vcodec libx264 -crf 20 (where CFR accepts value from the 0-51 range: 0 is lossless, 23 is default, and 51 is worst possible. A lower value is a higher quality and a subjectively sane range is 18-28. Consider 18 to be visually lossless or nearly so)

apt

  • apt list -a <packagename>
  • apt install <packagename>=<packageversion>

fontconfig

  • fc-cache -fv refresh cache
  • fc-match serif, fc-match sans-serif, fc-match monospace check default font families

SSH

GPG

Use ECC + ECC (ed25519) with Curve 25519 (cv25519) as elliptic curve.

  • gpg --list-keys list keys with key-ids
  • gpg --list-keys --with-fingerprint list keys in keyring with fingerprints/subkeys
  • gpg --list-kets --format LONG also show subkeys ID
  • gpg --full-generate-key key generation wizard
  • gpg --full-generate-key --expert enable more encryption algorithms
  • gpg --import $FILE import key (both public/public parts)
  • gpg --edit-key $FINGERPRINT, gpg> trust trust
  • gpg --armor --export $KEYID ASCII encoded export
  • gpg --export-secret-keys -a $KEYID
  • gpg --keyserver http://keys.gnupg.net:11371/ --send-key $KEYID, submit to keyserver
  • wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add - download and add key as trusted pipe

git

  • git log -10 --format="%cd %s"
  • git log -1 --format=%cd
  • git remote set-url --add origin ORIGIN origin push to more than one git repository server at a time
  • After having merged a branch, to continue working on that branch, syncing with master:
    # Checkout the default branch (master or develop)
    git checkout master
    git pull
    # Delete the local branch
    git branch -D nomeBranch
    # Delete remotely
    git push origin --delete nomeBranch
    # Recreate it locally
    git branch -m 'nomeBranch'
    # During the first push, specify the branch to remotely track
    git push --set-upstream origin nomeBranch
    # Pushing to a remote branch with a different Name
    git push origin local-name:remote-name
    # Amend and sign a commit (DCO)
    git commit --amend --signoff
    git push --force-with-lease
    
configuration

Adding --global applies these settings as default/system wide and not only in current repo.

  • git config user.email $EMAIL
  • git config user.name $NAME
  • git config gpg.program gpg set gpg executable
  • git config commit.gpgsign true enable gpg-signing commits
  • git config user.signingkey $FULLFINGERPRINT set default gpg key to use when signing commits

Common Locations

  • ~/.local/share/applications user-relative launchers
  • ` /usr/share/applications or /usr/local/share/applications` global launchers
  • ~/.local/share/user-places.xbel dolphin bookmarks