Skip to content

find

finds files or directories by name.

Terminal window
# Search file in root directory with name test.txt
find / -name "test.txt"
# search all the files ending with txt extension and getting its long listing
find . -maxdepth 1 -name "*.txt" -exec ls -l {} \;
# all files in home directory with size > 1MB
find ~ -type f -size +1M
# find all the files which has 777 permission, and change their permission to 644
find / -type f -perm 0777 -print -exec chmod 644 {} \;
OptionsDescription
-namename of the file or directory to search
-inamename of the file or directory to search, ignoring case
-mindepthstart searching after certain depth
-maxdepthlimit search to certain depth
-execexecute a command for each file found
-permsearch for file with specific permission
-groupsearch files owned by specific group
-usersearch files owned by specific user
-typef for files, d for directories, l for symbolic links, s for sockets, b for block special
-sizesize of the file or dir
Distro/OS/Package ManagerInstall Instruction
Centos/fedora(dnf, microdnf, rpm, yum)yum install findutils
Debian/ubuntuapt install findutils
Arch (pacman)pacman -Sy findutils
Alpine (apk-docker)apk add findutils