Skip to content

Instantly share code, notes, and snippets.

@mrandi
Last active June 17, 2019 10:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrandi/5606ac04ab331a1b54e8 to your computer and use it in GitHub Desktop.
Save mrandi/5606ac04ab331a1b54e8 to your computer and use it in GitHub Desktop.
du -ch | grep total
# list all services
sudo netstat --ltp
# find file
find ~/ -type f -name "*.*"
# find dir
find / -type d -name 'dir_name'
# grep in current dir for specific file type
grep -nr --include="*.yaml" --include="*.yml" "xxx" .
# find something in all files
find . -iname '*.java' | xargs grep -n 'xxx'
# open ports
netstat -antp
# port listen to:xxx
lsof -i :<port number>
#Linux - Find what application/process is using the pro, type:
sudo netstat -lpn |grep :8080
#Mac
lsof -n -i4TCP:8080 | grep LISTEN
#add and remove traffic over specific interface for some host
sudo /sbin/route add -host host.com -interface ppp0
sudo /sbin/route delete -host host.com -interface ppp0
#show routing table for ppp0 interface
netstat -rn | grep ppp0 | less
# list directory size
du -h -d=1
# http server
python -m SimpleHTTPServer 8080
python3 -m http.server 8181
# download java
wget --no-check-certificate --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" "http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz" -O "jdk-7u51-linux-x64.tar.gz"
&& tar -xvf jdk-7u51-linux-x64.tar.gz
# https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged
# To delete all branches that are already merged into the currently checked out branch:
git branch --merged | grep -v "\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d
# search in git
git log --all -S'string'
git grep <regexp> $(git rev-list --all)
# update all git repo in one shot
for D in `find . -depth 1 -type d`; do echo "${D}" && git -C "${D}" pull; done
#show public ssh key
ssh-add -L
# curl
curl -w "@curl-format.txt" -o /dev/null -s "http://google.com/" # https://stackoverflow.com/questions/18215389/how-do-i-measure-request-and-response-times-at-once-using-curl
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
# Cleanup volume
docker volume rm $(docker volume ls -qf dangling=true)
# List all volume
docker volume ls
#run locally pg with username and pwd = postgres
docker run -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment