Skip to content

Instantly share code, notes, and snippets.

@Sysa
Last active May 3, 2024 10:52
Show Gist options
  • Save Sysa/0fb41f97dd0488c672f840255e3bee47 to your computer and use it in GitHub Desktop.
Save Sysa/0fb41f97dd0488c672f840255e3bee47 to your computer and use it in GitHub Desktop.
linux/unix cheatsheet
disk usage (https://superuser.com/a/1573074/619805):
sudo du -hsx /* | sort -rh | head -n 40
du -schx .[!.]* * | sort -h
get proc envs:
sudo cat /proc/803/environ | xargs -0 env -i
get public IP from CLI:
dig +short myip.opendns.com @resolver1.opendns.com
------
ssh tunnels (with -L but with key auth):
`~/.ssh/config`:
Host computeinstance
HostName 20.22.222.222
User azureuser
Port 50001
IdentityFile ~/.ssh/id_rsa
ForwardAgent yes
LocalForward 6006 127.0.0.1:6006
check active tunnels:
`lsof -i -n | egrep '\<ssh\>'`
---
bash check port:
$ timeout 2 bash -c "</dev/tcp/HOST.com/80"; echo $?
0 -> means good
127 -> bad, port closed/firewall/vNet
124 -> port reachable but closed/disabled
macOS time shift:
sudo sntp -sS pool.ntp.org
Get amout of lines in the codebase:
find . -name '*.py' -o -name '*.tf' -o -name '*.yaml' -o -name '*.yml' | xargs wc -l
if you need an indicator of consumed space in your compute instance while dockering:
watch -n5.5 --no-title "df -h | head -2 | grep -o '.\{5\}$'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment