My Software Universe Cheat Sheet
- 1 minList of useful commands for all technologies I regularly use.
Content:
JVM
Show running Java processes:
jps
Show thread stack trace for Java process:
jstack <PID>
Every 500ms print GC cause of the running JVM process
jstat -gccause <PID> 500ms
Remote debugging
java -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n
Shell
misc
Show all process as a tree
ps ufax
Show processes listening on ports
sudo netstat -lneutp
Watch file size of the file
watch du -sh file.txt
Find text in files
find . -name "*.txt" -exec grep -n -H "text" {} \\;
netcat
listen on specific port and forward output to the file
nc -l 5555 > output.raw
connect to host and port and send some text
nc localhost 5555
> Hello World!
tcpdump
Sniff communication on localhost interface (lo
) and port 5555
and write it to the file
tcpdump -i lo -w recording.pcap port 5555
awk
Remove empty lines from a file
awk 'length($0) > 0 {print $0}' file_with_blanks > new_file_wo_blanks
Print first column but wrap value in double quotes
head file.csv | awk -F\; '{print "\x22"$1"\x22"}'
sed
Escape quotes in the file $f
sed 's/\"/\\\"/g' $f
Tmux
Set start directory for current tmux session Press Ctrl+B, :
and then write attach -c /path/to/start/directory
Rename current session: Ctrl+B, $
AWS CLI
List all instances with the project tag set to <value>
aws ec2 describe-instances --filters "Name=tag:Project,Values=<value>" --output text --query 'Reservations[*].Instances[*].[ImageId,State.Name,PublicIpAddress,Tags[*]]' | column -t