20+ Find command which you can use daily

  • Post last modified:April 27, 2021
  • Reading time:4 mins read

Everyone says find command is powerful utility to use every day let’s really find why it says?

From the name itself you can get what this command will do right?

We will see where we can apply find command in Linux

Let’s Begin

There are numbers of parameter we can use with find command.

-min, -anewer, -cmin, -cnewer, -context, -ctime, -daystart, -delete, -depth, -empty, -exec, -execdir, -executable, -false, -fls, -follow, -fprint, -fprint0, -fprintf, -fstype, -gid, -group, -help, -ignore_readdir_race, -ilname, -inum, -ipath, -iregex, -iwholename, -links, -lname, -ls, -maxdepth, -mindepth, -mmin, -mount, -mtime, -name, -newer, -nogroup, -noignore_readdir_race, -noleaf, -nouser, -nowarn, -ok, -okdir, -path, -perm, -print,-print0, -printf, -prune, -quit, -readable, -regex, -regextype, -samefile, -size, -true, -type, -uid, used, -user, -version, -warn, -wholename, -writable, -xdev, -xtype.

We will explain every parameter how we can use it

1. Find all the file which is used in last 30 Minutes.

If you need to find all the which is accessed in last 30 minutes or whatever other time.

$ find / -amin -30

2. Find all the changed file in last 1 hours.

If you need to check which file has been changed recently or any specific time then you can use this.

$ find / -cmin -60

3. Find File using name in current Directory

If you want to find a specific file name which name is ” showcase.txt”.

$ find . -name showcase.txt

4. Find Files under home directory

When you want to find a specific name under a specific directory then you can follow these steps

$ find /home -name showcase.txt

5.Find Files Using name with ignoring case

If you want to find the file or directory name then which contains both capital and small letters.

$ find /showcase -iname file.txt

Read this:

Permission Command in Linux: chmod

6. Find Directories Using Name

Find all directories name whose name is showcase in a current directory.

$ find / -type d -name showcase

7. Find using extension name like .txt

When you need to find all the txt format file in directory then you can use this command.

$ find . -type f -name filename.txt

8. Find file which has read permissions

When you want to know which file has what permission then you can use the -perm parameters.

If you want to check read permission in the currently directory you can use this.

$ find showcase/. -perm u=r

9. Find file which has both read and write permissions

You can even check both read and write files.

$ find showcase/. -perm u=rw

10. Find all file or directory permission using 775

If you want to know the file using octal bits that also you can do.

$ find showcase/. -perm 775

11.Find directories with 777 permissions

When you wan to check which directories has 777 permission then you use -type and specify d as directory.

$ find / -type d -perm 777

12.Find file which has 777 permissions

When you wan to check which file has 777 permission then you use -type and specify f as file.

$ find / -type f -perm 777

13. Find file size

If you want to check file size of all the file.

$ find -type f -exec du -Sh {} \;

14.Change file permission

If you want to change permission of only file then you can use this.

$ find -type f -exec chmod 774 {} \;

15.Change directory permissions

You want to change all the directory to 744.

$ find -type d -exec chmod 774{} \;

16. Change all the 775 permissions

If you want to find whichever file has 755 and change permission to 644.

$ find -perm 0775 -print -exec chmod 644 {} \;

17. Remove file using find command

Now we see how we can find file and delete.

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

18. Find the all empty files

If you have a text file which is empty and you want to know which file is empty.

$ find -type f -empty 

19.Find all the empty directories

When you want to know which directories is empty then you can use this too.

$ find -type d -empty 

20.Find all the hidden files

If you want to find all the hidden files

$ find -type f -name ".*"
Like what you read? Please share it with others.

Leave a Reply