Find all the files in /home with name hello.txt.
find /home –name hello.txt
Find the files with name hello.txt and in present working directory
find . –name hello.txt
OR
find –name hello.txt
Find all the files with name hello.txt but ignoring the case of file names.
find /home –iname hello.txt
-iname option is used to mention ignore the case sensitivity of a file.
Search for files depending on their File types
Search for only directories whose name is var in / directory
find / -type d –name var
Search for an mp3 files whose name is nagada.mp3
find / -type f –name nagada.mp3
FILE TYPES :
f Regular file
d Directory file
b Block file
c Character file
p Pipe file
l Symbolic link file
s Socket file
Search for a file name hello.txt and its permissions are 775
find / -perm 775 –name hello.txt
Searching files with SUID bit set and file permissions are 755
find / -perm 4755
Find SGID bit set files with 644 permissions
find / -perm 2644
Find Sticky bit set files in my system with permissions 551
find / -perm 1551
Search for all the files whose SUID bit is set
find / -perm /u=s
Search for all the files whose SGID bit is set
find / -perm /g+s
Note: We can use = or + interchangeably to check if a permissions is set or not.
Search for all the files whose StickyBit is set
find / -perm /o=t
Search for all the files whose owner permissions is read only.
find / -perm /u=r
Search for all the files which have user, group and others with executable permissions
find / -perm /a=x
Search for all the files with name hello.txt and the owner of this file is Shaan
find / -user Shaan –name hello.txt
Find all the files whos name is hello.txt and owned by a group called admplat
find / -group admplat –name hello.txt
Search by Modified date and time
Search for a file hello.txt whose file status is changed more than 90 days back
find / -ctime +90 –name hello.txt
Search for all the files which are modified exactly 90 days back
find / -mtime 90
Search for all the files with name test.txt which is accessed less than 90 days
find / -atime -90
Find all the files which are modified more than 90 days back and less than 180 days
find / -mtime +90 –mtime -180
Find all the files changed less than 30 mins
find / -cmin -30
Find all the files modified exactly 30 mins back
find / -mmin 30
Find all the files accessed more than 30 mins back
find / -amin +30
Find all the files which are modified more than 5mins back and less than 25 mins
find / -mmin +5 –mmin -25
Get all the files which are created later to a file created
find / -newer test.txt
Search for files/folders by size
Search for files whose size is more than 10 bytes
find / -size +10c
Search for files which are exactly 10 kb in /opt folder
find /opt –size 10k
Search for files which are less than 10MB in /var folder
find /var –size -10M
Search for files which are more than 1GB size in /usr folder
find /usr –size +1G
Find all the empty files in my system
find / -size 0k
No comments:
Post a Comment
Note: only a member of this blog may post a comment.