Introduction
In Linux while you are working with shell, Find Command in Linux is one of the most beneficial one wherein you can check all documents/folders on you server. It allows to search for a particular textual content string in a file or files. The command sends the specified strains to the same old output device.
Let us see unique locate commands with sort of filters and parameters.
Find Commands in linux with Examples
1. This command exams all files in /domestic directory with the call fastwebhost.Txt
locate /domestic -name fastwebhost.Txt
2. This discover command in linux exams all documents in modern running listing with the call fastwebhost.Txt
discover . -call fastwebhost.Txt
three. This command will search all files in home directory irrespective to case sensitive.
Find /domestic -iname FastWebhost.Txt
4. This command assessments all directories with a particular call like "usr" in root folder
discover / -type d -name usr
five. This locate command in linux assessments all tmp files with report call tmp.Php
locate / -type f -name tmp.Personal home page
Check documents/folders as in keeping with their permissions
6. The under command can take a look at all "check.Personal home page" documents with 777 permissions
find / -perm 777 -call check.Personal home page
7. The beneath discover command in linux can test documents with SUID bit set with permissions 755
"SUID" is defined as giving temporary permissions to a consumer to run a program/record with the permissions of the report owner instead that the consumer who runs it.
Locate / -perm 4755
eight. How to look SGID bit set files with 644 permissions
"SGID" is nothing but assigning transient permissions to a user to run a program/file with the permissions of the file group permissions to grow to be member of that organization to execute the document. In simple phrases users will get document Group's permissions while executing a Folder/file/application/command. SGID is just like SUID.
Discover / -perm 2644
nine. The underneath Command checks sticky bit documents with permissions 755
A Sticky bit is a permission bit that is set on a report or a directory that we could most effective the proprietor of the document/directory or the basis consumer to delete or rename the file. No other user is given privileges to delete the file which changed into created by means of any other consumer.
find / -perm 1755
Using Find command primarily based on users and groups
10. This command checks all the documents with take a look at.Txt that's owned by means of a specific person.
Locate / -consumer fastwebhost -name test.Txt
11. This discover command in linux tests all the files with check.Txt which is owned with the aid of a particular group.
Discover / -group fastwebhost -call take a look at.Txt
Find command to search the modified date & time of a particular record( In Days)
12. This command look for the documents which have been changed more than 90 days lower back
locate / -ctime +ninety take a look at.Txt
13. This command searches all documents which were changed exactly 90 days lower back
find / -mtime ninety
14. This command searches all files which had been get right of entry to less than 90 days
discover / -atime -ninety
15. This command will seek all documents which have been changed in between two time ranges, like more than 90 days and much less than 180 days.
Find / -mtime +ninety -mtime -180
Find command to search when the documents turned into changed (Short period, like in mins/hours)
16. This command fiinds all files which had been modified less than 45 mins.
locate / -cmin -forty five
17. The under command to check all documents with ultimate exchange log if it's miles exatly beneath 45 mins.
Discover / -mmin 45
18. This command enables you check all files that have been modified extra than forty five minutes lower back.
Find / -amin +45
19. It unearths all files modified after 6 minutes and under 30 minutes.
Find / -mmin +6 -mmin -30
20. Lets see how to check the record which were created after growing check.Txt report
locate / -newer take a look at.Txt
Find Command to search files/folders based on length
21. It searches for the files/folders which can be greater than 10 bytes in size.
Locate / -length +10c
22. It reveals the document/folders which had been extra than 20 kb(kilo bytes) in any of the folder
discover /tmp -size 20k
23. The following command searches the document/folder with less than 10MB in a folder
locate /tmp -length -10M
24. The below command will search all documents/folders that are greater than 1GB
locate / -size +1G
25. To search all empty files in server
find / -size 0c
26. Find all of the files that are with more than length 50MB and less than 500GB and the proprietor of the record is take a look at and the file name is fastwebhost.Txt in /rapid folder.
Locate /rapid -size +50M -size -500M -consumer test -iname fastwebhost.Txt
Executing instructions on the documents/folder observed with "find" command
Caution: When the use of -exec option that you are going to analyze under, you should be greater cautious. If you don't use accurately this may dispose of/alternate some thing.
There are some instances when you want to execute commands on the observed files with discover command. -exec is the option used in locate command to execute shell commands immediately on determined files/folders. Let’s talk this with a simple instance.
27. The under command with -exec alternative will seek /tmp folder for *pass.* file and listing the output in your display.
Discover /tmp -iname *skip.* -exec ls -ld ;
28. The under command reveals the record test.Txt with the fast1 as proprietor in /domestic folder, than it's going to alternate the ownership to fast2 via executing the chown command the use of -exec
discover /home -user fast1 -name test.Txt -exec chown fast2.Fast2 ;
29. The under command will find the record "bypass.Txt" under /tmp folder and attempt to grep the word "Name" the use of executive command.
Find /tmp -iname pass.Txt -exec grep "Name" ;
30. This command will search for check.Txt.Db document beneath the person fast and change the file permission to 755 the usage of -exec option.
Discover /var/named -consumer speedy -name take a look at.Txt.Db -exec chmod 755 ;
In Linux while you are working with shell, Find Command in Linux is one of the most beneficial one wherein you can check all documents/folders on you server. It allows to search for a particular textual content string in a file or files. The command sends the specified strains to the same old output device.
Let us see unique locate commands with sort of filters and parameters.
Find Commands in linux with Examples
1. This command exams all files in /domestic directory with the call fastwebhost.Txt
locate /domestic -name fastwebhost.Txt
2. This discover command in linux exams all documents in modern running listing with the call fastwebhost.Txt
discover . -call fastwebhost.Txt
three. This command will search all files in home directory irrespective to case sensitive.
Find /domestic -iname FastWebhost.Txt
4. This command assessments all directories with a particular call like "usr" in root folder
discover / -type d -name usr
five. This locate command in linux assessments all tmp files with report call tmp.Php
locate / -type f -name tmp.Personal home page
Check documents/folders as in keeping with their permissions
6. The under command can take a look at all "check.Personal home page" documents with 777 permissions
find / -perm 777 -call check.Personal home page
7. The beneath discover command in linux can test documents with SUID bit set with permissions 755
"SUID" is defined as giving temporary permissions to a consumer to run a program/record with the permissions of the report owner instead that the consumer who runs it.
Locate / -perm 4755
eight. How to look SGID bit set files with 644 permissions
"SGID" is nothing but assigning transient permissions to a user to run a program/file with the permissions of the file group permissions to grow to be member of that organization to execute the document. In simple phrases users will get document Group's permissions while executing a Folder/file/application/command. SGID is just like SUID.
Discover / -perm 2644
nine. The underneath Command checks sticky bit documents with permissions 755
A Sticky bit is a permission bit that is set on a report or a directory that we could most effective the proprietor of the document/directory or the basis consumer to delete or rename the file. No other user is given privileges to delete the file which changed into created by means of any other consumer.
find / -perm 1755
Using Find command primarily based on users and groups
10. This command checks all the documents with take a look at.Txt that's owned by means of a specific person.
Locate / -consumer fastwebhost -name test.Txt
11. This discover command in linux tests all the files with check.Txt which is owned with the aid of a particular group.
Discover / -group fastwebhost -call take a look at.Txt
Find command to search the modified date & time of a particular record( In Days)
12. This command look for the documents which have been changed more than 90 days lower back
locate / -ctime +ninety take a look at.Txt
13. This command searches all documents which were changed exactly 90 days lower back
find / -mtime ninety
14. This command searches all files which had been get right of entry to less than 90 days
discover / -atime -ninety
15. This command will seek all documents which have been changed in between two time ranges, like more than 90 days and much less than 180 days.
Find / -mtime +ninety -mtime -180
Find command to search when the documents turned into changed (Short period, like in mins/hours)
16. This command fiinds all files which had been modified less than 45 mins.
locate / -cmin -forty five
17. The under command to check all documents with ultimate exchange log if it's miles exatly beneath 45 mins.
Discover / -mmin 45
18. This command enables you check all files that have been modified extra than forty five minutes lower back.
Find / -amin +45
19. It unearths all files modified after 6 minutes and under 30 minutes.
Find / -mmin +6 -mmin -30
20. Lets see how to check the record which were created after growing check.Txt report
locate / -newer take a look at.Txt
Find Command to search files/folders based on length
21. It searches for the files/folders which can be greater than 10 bytes in size.
Locate / -length +10c
22. It reveals the document/folders which had been extra than 20 kb(kilo bytes) in any of the folder
discover /tmp -size 20k
23. The following command searches the document/folder with less than 10MB in a folder
locate /tmp -length -10M
24. The below command will search all documents/folders that are greater than 1GB
locate / -size +1G
25. To search all empty files in server
find / -size 0c
26. Find all of the files that are with more than length 50MB and less than 500GB and the proprietor of the record is take a look at and the file name is fastwebhost.Txt in /rapid folder.
Locate /rapid -size +50M -size -500M -consumer test -iname fastwebhost.Txt
Executing instructions on the documents/folder observed with "find" command
Caution: When the use of -exec option that you are going to analyze under, you should be greater cautious. If you don't use accurately this may dispose of/alternate some thing.
There are some instances when you want to execute commands on the observed files with discover command. -exec is the option used in locate command to execute shell commands immediately on determined files/folders. Let’s talk this with a simple instance.
27. The under command with -exec alternative will seek /tmp folder for *pass.* file and listing the output in your display.
Discover /tmp -iname *skip.* -exec ls -ld ;
28. The under command reveals the record test.Txt with the fast1 as proprietor in /domestic folder, than it's going to alternate the ownership to fast2 via executing the chown command the use of -exec
discover /home -user fast1 -name test.Txt -exec chown fast2.Fast2 ;
29. The under command will find the record "bypass.Txt" under /tmp folder and attempt to grep the word "Name" the use of executive command.
Find /tmp -iname pass.Txt -exec grep "Name" ;
30. This command will search for check.Txt.Db document beneath the person fast and change the file permission to 755 the usage of -exec option.
Discover /var/named -consumer speedy -name take a look at.Txt.Db -exec chmod 755 ;
0 Comments
Post a Comment