Handy Linux commands

08/22/2016

Recursively Change permissions

  • To change file permission, sudo find /var/log/test -type f -exec chmod 777 {} \;
  • To change directory permission, sudo find /var/log/test -type d -exec chmod 777 {} \;

Search multiple files:

  • find . -name "*.log" | xargs grep -i <something>
  • grep -B x -A x file.log

Snapshot Date

  • date -u +%Y/%m/%d-%H:%M

Linux Permissions Cheat Sheet

Owner Group World
4 read (r)
2 write (w)
1 execute (x)
7 = 4+2+1 (read/write/execute)
6 = 4+2 (read/write)
5 = 4+1 (read/execute)
4 = 4 (read)
3 = 2+1 (write/execute)
2 = 2 (write)
1 = 1 (execute)