Below is a compilation of command line tips that have helped me over the years. As this is a cheat sheet, it will be updated over time to include new cheats and to maintain existing ones.

MkDocs

  1. mkdocs new my-project
  2. mkdocs build -clean
  3. mkdocs serve
  4. mkdocs gh-deploy -clean

Set gdm3 as default display

sudo dpkg-reconfigure gdm

Boot into terminal

ctrl + alt + F1

Create bootable flash drive

  1. open terminal
  2. run diskutil list
  3. identify which disk corresponds to your USB stick
  4. diskutil unmountDisk /dev/rdisk2
  5. sudo dd if=/path/to/ubuntu.iso of=/dev/rdisk2 bs=1m

Checksum on Mac

shasum -a 256 /tmp/1.iso md5 /tmp/1.iso

Kill process in Windows

  1. netstat -ano
  2. netstat -ano | find [port number]
  3. taskkill /F /PID [PID number]

Invert Mouse Scroll Wheel in Windows

Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA 0 | ForEach-Object { Set-ItemProperty $_.PSPath FlipFlopWheel 1 }

Make file executable

chmod +x script.sh

Exclude all “permission denied” messages from “find”

find . ! -readable -prune

Add GitHub as known host

ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts

Restarting linux without doing an automatic fsck

  1. shutdown -rf now
  2. if there’s a read-only file system, you can remount it - BUT usually a system is read-only if it’s about to be unreadable altogether, so be careful
  3. mount -o remount /dev/sda1

CentOS enable access to web server

iptables -I INPUT -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT
# to make the changes permanent
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT
service httpd restart

Fixing the block size on a USB drive

sudo dd if=/dev/zero of=/dev/<id_of_your_device> bs=2048 oflag=direct

Pressing enter produces ^M instead of a newline

stty sane

Remove untracked files from working tree (Git)

git clean -f -n
git clean -f