Electric Grimoire
Disk

Show disk usage: df -h
List filesizes: du -sh * | sort -h
Show disks and mountpoints: lsblk
Mount ntfs partition in read/write mode: sudo mount -t ntfs -o rw,remount <device> <directory>
. Must unmount first if already mounted.
Ssh
Connect: ssh [-p <port>] [username@]<ip>
Copy files to: scp [-P <port>] <filepath> [username@]<ip>:<filepath>
Copy files from: scp [-P <port>] [username@]<ip>:<filepath> <filepath>
Run command: ssh [-p <port>] [username@]<ip> <command>
Specify hostnames in /etc/ssh/ssh_config
. They can be used in place of ip addresses.
Host <name>
HostName <ip>
Port <port>
Git
Clone: git clone <url>
Pull: git pull
Add: git add <path>
Commit: git commit
Push: git push
List branches, local and remote: git branch -a
Switch branches: git checkout <branch>
Create a branch: git branch <name>
. You'll still need to switch to it afterwards.
List previous commits: git log --oneline
Revert to previous commit: git checkout <hash> .
Clone with submodules: git clone --recurse-submodules <url>
Clone submodules later: git submodule update --init --recursive
Submodules are like their own repos. You can cd
inside and switch branches, push/pull, etc.
Apt
Fix interrupted upgrades: sudo dpkg --configure -a
Make & CMake
Makefile macro expanding to rule's target: $@
Makefile macro expanding to rule's prerequisites: $^
For CMake, make sure you're inside the ./build/
directory.
Configure: cmake ..
Build: cmake --build .
Graphical mode: cmake-gui
Curses mode: ccmake
C Tricks
if (*c >= '0' && *c <= '9') {
return *c - '0';
}
Custom assert message: assert(<condition> && "message");
Vim
Copy selection to system clipboard: "*Y
Paste from system clipboard: "*p
Fix indentation of entire file: gg=G
Save with sudo: :w !sudo tee %
System
Show overview: inxi -F
Images
Remove EXIF data: exiftool -all= -overwrite_original *.jpg
The remaining pages have yet to be deciphered. Please come back another time.