0% found this document useful (0 votes)
11 views5 pages

Find

The document provides a comprehensive list of commands using the 'find' utility in Unix/Linux for various file search and manipulation tasks. It includes commands to search for files and directories by name, permissions, modification times, user ownership, and file sizes, as well as commands to delete or change permissions of found files. Additionally, it explains the use of flags for specific search criteria, such as searching for empty files or files modified within a certain timeframe.

Uploaded by

suman.mitra2025
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views5 pages

Find

The document provides a comprehensive list of commands using the 'find' utility in Unix/Linux for various file search and manipulation tasks. It includes commands to search for files and directories by name, permissions, modification times, user ownership, and file sizes, as well as commands to delete or change permissions of found files. Additionally, it explains the use of flags for specific search criteria, such as searching for empty files or files modified within a certain timeframe.

Uploaded by

suman.mitra2025
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 5

1

List all files found in the current hierarchy, and all the hierarchy below /home/xyz
$ find. /home/XYZ

Search for a file by the name abc in the current directory and its hierarchy
$ find ./ -name abc

Search for a directory by the name xyz in the current directory and its hierarchy

$ find ./ -type d -name xyz

Search for a file by the name abc.txt below the current directory, and prompt the user
to delete each match.

$ find ./ -name abc.txt -exec rm -i {} \;

Search for files that were modified in the last 7 days below the current directory

$ find ./ -mtime -7

Search for files that have all permissions set in the current hierarchy
$ find ./ -perm 777

Find all the files whose name is tecmint.txt and contains both capital and small
letters in /home directory.

# find /home -iname tecmint.txt

Find all php files whose name is tecmint.php in a current working directory.
# find . -type f -name tecmint.php
Find all php files in a directory.
# find . -type f -name "*.php"

Find all the files whose permissions are 777.


2

# find . -type f -perm 0777 -print


Find all the files without permission 777.
# find / -type f ! -perm 777

Find all the Sticky Bit set files whose permission are 551.
# find / -perm 1551

Find all SUID set files.


# find / -perm /u=s

Find all SGID set files.


# find / -perm /g=s

Find all Read Only files.


# find / -perm /u=r

Find all Executable files.


# find / -perm /a=x

Find all 777 permission files and use chmod command to set permissions
to 644.

# find / -type f -perm 0777 -print -exec chmod 644 {} \;


3

Find all 777 permission directories and use chmod command to set
permissions to 755.

# find / -type d -perm 777 -print -exec chmod 755 {} \;


To find a single file called tecmint.txt and remove it.

find . -type f -name "tecmint.txt" -exec rm -f {} \;

To find all empty files under certain path.

# find /tmp -type f -empty

To file all empty directories under certain path.

# find /tmp -type d -empty

To find all hidden files, use below command.

# find /tmp -type f -name ".*"

To find all or single file called tecmint.txt under / root directory of owner root.
# find / -user root -name tecmint.txt

To find all files that belongs to user Tecmint under /home directory.
# find /home -user tecmint

To find all files that belongs to group Developer under /home directory.
4

# find /home -group developer

To find all .txt files of user Tecmint under /home directory

# find /home -user tecmint -iname "*.txt"

 -mtime +60 means you are looking for a file modified 60 days ago.
 -mtime -60 means less than 60 days.
 -mtime 60 If you skip + or – it means exactly 60 days.

To find all the files which are modified 50 days back.


# find / -mtime 50

To find all the files which are accessed 50 days back.


# find / -atime 50

o find all the files which are modified more than 50 days back and less
than 100 days.
# find / -mtime +50 –mtime -100

To find all the files which are changed in last 1 hour.


# find / -cmin -60

o find all the files which are modified in last 1 hour.


# find / -mmin -60
5

To find all the files which are accessed in last 1 hour.


# find / -amin -60

To find all 50MB files, use.


# find / -size 50M

To find all the files which are greater than 50MB and less than 100MB.
# find / -size +50M -size -100M

o find all 100MB files and delete them using one single command.
# find / -type f -size +100M -exec rm -f {} \;

Find all .mp3 files with more than 10MB and delete them using one single
command.
# find / -type f -name *.mp3 -size +10M -exec rm {} \;

You might also like