Date Added: 25/09/2017
Linux Commad Find (serach , change ,modfy, criteria ,recursive, file size)

Linux Commad Find  one of the most frequently used commad in linux

below is same example 

Find by name 

find . -name filename.txt

Find by file permission 

code below find all files with permission 777
find . -type f -perm 0777 -print 

code below find all directory with permission 777
find . -type d -perm 0777 -print

Find and execute code chmod to modify file permission

example below find directory(folder) in current folder and execute chmod code to modify file permission
find . -type d -exec chmod 0755 {} \;

example below find files in current folder and execute chmod code to modify file permission
find . -type f -exec chmod 0644 {} \;

Find and excute chown to change owner of files in current folder  (multiple file changing)

for files :
find . -type f  -exec chown newuser:newgroup {} \;

for folders :
find . -type d  -exec chown newuser:newgroup {} \;

for a file extension like "*.php" :
find . -type f -name "*.php" -exec chown newuser:newgroup {} \;

 

find file by file size 
Code belows Finds files larger than 50 MB in current directory 
 find . -type f -size +50M -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

Last Update: 19/12/2017 Posted by: müslüm ÇEN

Not Commented Yet !
Please login in order to comment . Login