Frequently Used Linux Commands

(and yet we cant remember the exact command)

  • Tar tgz: tar -czvf abc.tgz /path/to/folder
  • Untar tgz: tar -zxvf myfile.tgz
  • Create softlink: ln -s filepath link
  • Look for huge folder:
du -h ./ | sort -rh

## larger than 1GB only
du -h -t 1G ./ | sort -rh
  • merge file into 1 line delimited by comma: cat myfile.txt | awk '{print}' ORS=','
  • extract only line appear in left file: comm -23 left.txt right.txt
  • delete all files recursively, keep folders: find . -type f -delete
  • delete jpeg files older than 1 days recursively: find /path/to/files* -mtime +1 -type f -name '*.jpeg' -delete