This is a "cheat sheet" style collection of bash and other snippets, mainly for myself to refer to.
# works on MacOS
$ diff --side-by-side --color=always <file1> <file2> | less -R
# show only lines in file2 that are not in file1
$ comm -1 -3 <(sort -u file1.txt) <(sort -u file2.txt)
# show only lines in file1 that are not in file2
$ comm -2 -3 <(sort -u file1.txt) <(sort -u file2.txt)
# show only lines in both
$ comm -1 -2 <(sort -u file1.txt) <(sort -u file2.txt)
# MacOS
$ somecmd | pbcopy
$ pbcopy < somefile
$ pbpaste | somecmd
$ pbpaste > somefile
# Ubuntu
$ sudo apt-get install xclip
$ somecmd | xclip -selection clipboard
# MacOS
$ brew install smartmontools && sudo smartctl —all /dev/disk0
# MacOS
$ diskutil info `diskutil list | grep "<VolumeName>" | tr ' ' '\n' | grep "^disk"` | grep "Space\|Identifier\|Mount"
$ sudo killall unity-panel-service
# restrict chars to listed ranges
$ LC_ALL=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 32 ; echo
$ find / -xdev -type f -size +100M
$ rsync -vPz -e 'ssh -i /full/path/to/key' /local/file user@host:/remote/location/
$ ps ax | grep '[j]ava' | cut -c -100
# use Ctrl+R then start typing any portion of the command
$ mkpasswd -m SHA-256 [-S testsalt] [testpassw0rd]
# reboot (if you have may downloaded a newer kernal since rebooting)
$ uname -r (do not remove this one...)
$ sudo dpkg --list 'linux-image*' | awk '{ if ($1=="ii") print $2}' | grep -v `uname -r`
$ sudo apt-get purge <linux-image-...-from-above> (repeat for each to remove)
$ sudo update-grub2
# reboot (optional)
$ sudo apt-get autoremove
# linux
$ zcat <file> | ...
# MacOS (thanks to https://serverfault.com/a/704521/152493)
$ gunzip -c <file> | ...
# python 2.7, serve on port 8080
$ python -m SimpleHTTPServer 8080
$ ssh -L 1443:<host1>:443 username@<host2>
$ ssh -o "ServerAliveInterval 60" -o "ServerAliveCountMax 1" username@host
$ sudo tcpdump -nni eth0 port 8443
$ sudo tcpdump -vvnni ens3 port 8140
$ sudo netstat -atunp
$ sudo ss -ltnp # listening tcp sockets ; use -lunp to list listening udp sockets
$ for SOMEPORT in 123 456 789; do sudo ssh -q -fN -L $SOMEPORT:<hostA>:$SOMEPORT you@<hostB-that-can-access-hostA>; done
# what does --track do?
$ git checkout --track origin/development
$ git checkout development
$ git checkout -b new_branch [from-branch]
# i always use -u here... any reason to not use -u?
$ git push -u origin new_branch
$ git checkout master
$ git merge --no-ff development
$ cd ~/some/repo
$ git fetch --all
$ git reset --hard origin/development
$ git checkout master # checkout master branch in source repo
$ cd /path/to/mirror
$ git clone --mirror /path/to/source-proj
$ cd /path/to/source-proj
$ git push --mirror /path/to/mirror/source-proj.git
$ git tag -m "message for the tag" "tag-name"
$ git push origin --tags
$ git show --name-status [<commit>]
$ git rebase -i HEAD~3
$ mvn clean package -Dmaven.test.skip=true
$ mvn dependency:tree -Dincludes=groupid:artifactid
© 2024 Phil Thompson
‧
All Rights Reserved
‧
Terms
‧
Privacy Policy
‧
Disclaimer
About
‧
Archive
‧
GitHub
‧
Tip Jar
‧
RSS