Useful Linux commands

30 || 0  || 2018-04-18 07:42:16 || root || || Bash

Here is just number of different useful Linux shell commands

  • Show ports used by process
  • Release deleted files
  • Archive log files with maximum compression level

# Show ports used by process
sudo netstat -ltpn | grep apache

# Release deleted files
sudo lsof | grep "(deleted)$" | sed -re 's/^\S+\s+(\S+)\s+\S+\s+([0-9]+).*/\1\/fd\/\2/' | while read file; do sudo bash -c ": > /proc/$file"; done

# Archive log files with maximum compression level
time find . -type f -name "*.log" -exec gzip -9 '{}' ';'