Troubleshooting (files):
Find a file or directory
find / -type f -name "filename" 2>/dev/null
find / -type d -name "dirname" 2>/dev/null
find files that contain a pattern
find . -type f -exec grep -l 'version' {} \;
Troubleshooting (system):
Find a file or directory
find / -type f -name "filename" 2>/dev/null
find / -type d -name "dirname" 2>/dev/null
check if machine is a vm or barebone
dmidecode -s system-manufacturer
check folder disk usage
du -hs * | sort -h
check open port
(echo > /dev/tcp/10.254.4.54/22) >/dev/null 2>&1 && echo "It's up" || echo "It's down"
check for listening ports
sudo lsof -i -P -n | grep LISTEN
sudo netstat -tulpn | grep LISTEN
sudo ss -tulpn | grep LISTEN
sudo lsof -i:22 ## see a specific port such as 22 ##
sudo nmap -sTU -O IP-address-Here
Troubleshooting (SSL):
Check expiry date on .pem file
openssl x509 -enddate -noout -in /path/to/certificate.pem
Maintenance:
dry-run an update on OS
sudo yum check-update
Check if a reboot is required
needs-restarting -r
remove cache of updates for old data
rm -rf /var/cache/yum
block icmp
sysctl -w net.ipv4.icmp_echo_ignore_all=1
File manipulation:
remove empty lines from file
sed -i '/^$/d' <filename>
Account control:
change to root
sudo -i
Grep sudo users
rm -f /tmp/names; for user in $(getent passwd | cut -d: -f1); do count=$((count+1)); if sudo -l -U "$user" | grep -q "ALL"; then echo "$user" >> /tmp/names; echo "Checked $count of $(getent passwd | cut -d: -f1 | wc -l) users."; fi; done; clear; cat /tmp/names; rm -f /tmp/names