Linux commands - find, ls and grep to list files and folders and execute commands

Some Linux commands using find and ls to list and execute commands

#Update Linux search index if you are unsure if the index is up to date
updatedb

#### Find ####
#Find directories (-d) having a specified name and permission
find  /some_path/ -type d -name "zimonitor_reporting" -perm 0777

#Find directories (-d) having a specified name and execute chmod to set permission
find  /some_path/ -type d -name "zimonitor_reporting" -exec chmod 0777 {} \;

#Find and remove CSV files older than 30 days
find /var/www/sites/default/files/feeder/ -name '*.csv' -mtime +30 -exec rm {} \;

#Find and remove feed or prep files older than 30 days
find /var/www/sites/default/files/feeder/ -name '*.feed' -mtime +30 -exec rm {} \;
find /var/www/sites/default/files/feeder/ -name '*.prep' -mtime +30 -exec rm {} \;

# Remove files with size zero
find /var/www/sites/default/files/feeder -size 222c -print0 |xargs -0 rm -f
# NOTE: Error generated if no file found for removal

# Remove empty folders
find /var/www/sites/default/files/feeder -type d -empty -exec rmdir {} \;
# Also, generates errors along the way. Safe to ignore.

#Remove all .SVN folders and files recurcive
find /var/www/sites/all/ -name '*.svn' -exec rm -rf {} \;
or
Change directory by 'CD' to location and:  find -name '*.svn' -exec rm -rf {} \;
-r is recursive and -f is force, it means it will not ask if you want to do this, make sure you are in right directory

#Find last modified files recursively. 10 = number o files listed
find . -type f -printf "%C@ %p\n" | sort -rn | head -n 10

#Find directory named "fonts"
find /-type d -iname fonts

#Find file or folder containing "serif" in the name
find -name '*serif*'

#### List ####
ls -l //nice list
ls -la //nice list + hidden files ".profile"

#### Grep ####
#Find in file located in path "/etc/apache2/"
grep -r "lookingfor" /etc/apache2/

#Find processes as begin with "search" (search*)
ps auxxw|grep search

#### Other ####
#Size of folder
du en mapps storlek
du -h (h= human readable)
Knowledge keywords: