A compilation of handy UNIX tools I use daily

# Text transformation
awk '{print $1}' # Print column 1
cut -d ' ' -f1 # Split by ' ' and cut first column
tail -n +2 # Exclude first line 
tr " " "\n" # Replace spaces with newlines

# Search
find / -name 'file.yaml' -type f # Find file by name
grep -r "text" file/path # Find text in files (-l to show only filenames)

# Archive
tar -tvf file.tar.gz # List archive content
tar -tvf file.tar.gz 'search pattern' # Find file in archive
tar -zxvf file.tar.gz filename # Extract single file
tar -zxvf file.tar.gz -C destination # Extract to destination
tar -zcvf dest.tar.gz sourcedir # Achive a directory

# SSH
ssh-add -K ~/.ssh/id_ed25519
ssh-keygen -R my-host.com # Remove host from known_hosts
ssh -L 8080:localhost:61208 host # Port-forward over ssh

# Telemetry
du -ah -d 1 # size of files and folders in the current directory

# Logs
journalctl --vacuum-size=100M # Rotate system logs

# SSL certificates
openssl x509 -in file.crt -text # Show certifiacte
openssl x509 -in file.crt -noout -enddate # Check expiration
openssl s_client -servername petrashov.ru -connect 127.0.0.1:443 # Check SSL certifiactes
curl -vi -o /dev/null --resolve petrashov.ru:443:127.0.0.1 https://petrashov.ru # Test HTTPS connection

# Users
adduser --disabled-password --shell /bin/bash wormi4ok
usermod --shell /bin/bash wormi4ok
usermod -aG sudo wormi4ok

# Debugging
strace -fp $PID # See what the process is doing
lsof -p $PID -ad 3,5,8 # Show info about file descriptors 3,5 and 8

# Firewall
iptables -L INPUT --line-numbers # List all rules in the chain
iptables -I INPUT 5 -m state --state NEW -p tcp --dport 443  -j ACCEPT # Allow new HTTPS connections
iptables -D INPUT 5 # Delete a rule by line number