It’s been a month i move back to Ubuntu as my primary OS. And i would like to write one of the most use command in Linux: “find”. This command is like a magic to search anything i want on my hard drive. I can find a text inside a file, or filter it for certain extension. I can search the files with latest modified time and also the file size.
List to use Linux command “find” that mostly used by me:
Find all PHP Files in a directory:
1find
. -
type
f -name
"*.php"
Find a file with a name:
1find
/etc/
-
type
f -name
"php.ini"
Find file with wrong permission (i use this because suPHP need file permission 755)
123456find
. -
type
f -perm 0777
#OR
find
. -
type
f -perm -o=w
#And to change them to correct permission, i use this command:
find
. -
type
f -perm 0777 -print -
exec
chmod
755 {} \;
find
. -
type
d -perm 777 -print -
exec
chmod
755 {} \;
Find unnecessary files and remove them. (Use this with extreme cautious):
123find
. -
type
f -name
"*.cache"
-
exec
rm
-f {} \;
#to remove empty files:
find
/tmp
-
type
f -empty -
exec
rm
-f {} \;
Find files by modified date:
1234#this will find all PHP files modified yesterday
find
. -
type
f -name
"*.php"
-mtime -1
#this will find all PHP files modified for the last 2 hours
find
. -
type
f -name
"*.php"
-mmin -120
Find files by the file size
12#Find zip files with more than 2MB
find
. -name
"*.zip"
-size +2M
Find a text in all files
12#this will find "die_dump" in all php files
find
. -name
"*.php"
-
exec
grep
-
in
"die_dump"
{} \; -print
In every port, you will be amused by the different activities such
as partying in the different dockside establishments.
Plug-in hybrid electric cars (PHEV) use a mix of traditional
fuels and electrical energy. Take cardboard boxes ashore to the dumpster as soon as you’re done.