Shell
Shell Scripts / Commands
Section titled “Shell Scripts / Commands”Delete line with specific string:
sed -i '/sha/d' ./*.logDelete line that not contain specific string:
sed -i '/sha\|cas/!d' ./*.logCheck existing connections
Section titled “Check existing connections”The most netstat command can be used on ss as well
# Listening(-l) TCP(-t)/UDP(-u) Portsnetstat -tlnp | lessnetstat -ulnp | less
# All Portsnetstat -nap | lessss -nap | lessIO Check:
Section titled “IO Check:”iostat -m /dev/xvdb 1 | while read a; do echo "$a" | awk '/xvdb/ {print strftime("%Y-%m-%d %T")",", $2 }' >> $(date +'%Y-%m-%d')-iops.csv; done
# Or save it to a .csv filesiostat -m /dev/xvdb 1 | while read a; do echo "$a" | awk '/xvdb/ {sum += $2; n++; print strftime("%Y-%m-%d %T")",", sum / n",", $2 }' >> $(date +%Y-%m-%d)-iops-with-average.csv; doneSome more useful commands
Section titled “Some more useful commands”Kernal panic: dmesg
tail: tail -n 5
ls: ls -lhS (-S: ordering by size; -t: ordering by time)
grep: grep -c (-c: count only)
Terminal Shotcut and Software’s Commands
Section titled “Terminal Shotcut and Software’s Commands”Attach and deattach the remote session (-t to attach specific session)
tmux a -d -t WordspaceSystem Backup
Section titled “System Backup”rsync --archive --one-file-system --hard-links \ --acls --xattrs --sparse \ --human-readable --numeric-ids --delete --delete-excluded \ --itemize-changes --verbose --progress \ --exclude='*~' \ --exclude-from=root.exclude \ src destReference: