Skip to content

Instantly share code, notes, and snippets.

@s2ks
Last active April 17, 2024 13:44
Show Gist options
  • Save s2ks/df5c6ba55ed27090577ad278c43490b0 to your computer and use it in GitHub Desktop.
Save s2ks/df5c6ba55ed27090577ad278c43490b0 to your computer and use it in GitHub Desktop.
A collection of linux related things that I either keep forgetting, or may forget in the future.

Laptop Battery management

  • tlp: power management
  • tlp-stat -b: see supported battery features
  • tlp setcharge: charge the battery to the specified amount

User management

  • useradd -m <username>: create a new user and their home directory
  • gpasswd -a <user> <group>: add a user to a group
  • chsh -l list available shells
  • chsh -s <bin> change default shell for current user

  • su -l <user>: log in as <user>

Files

Permissions

r=4
w=2
x=1

Disk usage

  • df -h: show disk usage in human-readable format
  • du -hs <file>: show disk usage of a file or folder

Bash

  • sh -c "echo hello\!": start a shell to execute a command.
  • [ -z ${var+x} ] && echo "var unset": check if a variable is set using parameter expansion

GPG

  • gpg --edit-key <user id>: key maintenance, including revoking and extending

Git

  • git update-index --skip-worktree <file> to ignore changes to the specified file

Vim

  • Ctrl+w <direction>: Switch to window pane
  • Ctrl+w s: Split current window horizontally
  • Ctrl+w v: Split current window vertically
  • Ctrl+w Shift+T: Move split window to tab
  • gt/gT: Navigate tabs
  • Ctrl+v Shift+I Multi cursor insert

Standards

Distribution specific

Arch Linux

  • paccache -rk1: clean the pacman cache leaving only the most recently installed version
  • paccache -ruk0: remove all uninstalled versions
  • The paccache script is provided by pacman-controb

Services

Openvpn

TODO

Postfix

TODO

Dovecot

TODO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment