Useful Linux/Unix commands

  • How do I find all files containing specific text?
grep -rnw '/path/to/somewhere/' -e 'pattern'
  • How i change the default file permissions (mask that controls file permissions)
umask
  • Untar (unzip) file
tar -zxvf archive.tar.gz
  • Copy files via rsync from one host to another
rsync -av [USER@]HOST[:PORT]/SOURCE [USER@]HOST[:PORT]/DEST
  • nslookup missing? Install dig
sudo apt-get install dnsutils
  • find without “Permission denied”
find / -name 'filename.ext' 2>&1 | grep -v "Permission denied"
  • flush dns cache
sudo systemd-resolve --flush-caches
  • show open ports
netstat -tulpn