find
Description
Section titled “Description”finds files or directories by name.
# Search file in root directory with name test.txtfind / -name "test.txt"
# search all the files ending with txt extension and getting its long listingfind . -maxdepth 1 -name "*.txt" -exec ls -l {} \;
# all files in home directory with size > 1MBfind ~ -type f -size +1M
# find all the files which has 777 permission, and change their permission to 644find / -type f -perm 0777 -print -exec chmod 644 {} \;Options
Section titled “Options”| Options | Description |
|---|---|
| -name | name of the file or directory to search |
| -iname | name of the file or directory to search, ignoring case |
| -mindepth | start searching after certain depth |
| -maxdepth | limit search to certain depth |
| -exec | execute a command for each file found |
| -perm | search for file with specific permission |
| -group | search files owned by specific group |
| -user | search files owned by specific user |
| -type | f for files, d for directories, l for symbolic links, s for sockets, b for block special |
| -size | size of the file or dir |
Installation
Section titled “Installation”| Distro/OS/Package Manager | Install Instruction |
|---|---|
| Centos/fedora(dnf, microdnf, rpm, yum) | yum install findutils |
| Debian/ubuntu | apt install findutils |
| Arch (pacman) | pacman -Sy findutils |
| Alpine (apk-docker) | apk add findutils |