How to find files or directory on Linux?? Explain find command with the help of examples.
The find command in Linux is very important to find the files and directory. Where find command is used?? When we need a file but we do not know in which directory it is, we need the specific directory but we do not know its location. So below is the widely used 6 important examples of the find command.
RECOMMENDED:17 linux Basic Commands with Examples
1.To find specific ‘directory’
Need to find directory name ‘arun’ under the / directory.
# find / -type d -name arun
2. find ‘file’ in a specified directory
find the file name ‘index.php’ under the /var/www directory.
# find /var/www -type f -name index.php
3. specific file in current directory
Dot represent the current directory.
# find . -type f -name index.php
4. To find ‘file’ when case-insensitive
Find the file name ‘arun.txt‘ under /home/arun directory where file name can be small or capital alphabet.
# find /home/arun -type f -iname arun.txt
5. How to find file from the ‘extension’
Here we will find all the files with the extension ‘.php’
# find /home/arun -type f -name "*.php"
6. find file with the specific permissions
To find all the files with the ‘664’ permissions.
# find . -type f -perm 664
Perfect !!! Here you have learned how to use the find command with the examples on Linux. Please feel free to write your feedback or questions in the below comment box.