Useful Examples Of Find Command In Linux

Useful Examples Of Find Command In Linux

Insight: List Of Useful Examples Of Find Command In Linux Operating Systems.

Let’s have look into the usage of Find command in Linux with the examples.

List Of Useful Examples Of Find Command In Linux

1. List All Files

Run the following command to list all files present inside the current directory in Linux.

sudo find -print

2. List All Files Present in a Specific Directory

Run the following command to list all files present in a particular or specific directory.

sudo find /folder

3. Search for a Specific File

Run the following command to search for a specific file in Linux. The following command will search for a file called itsubunt.txt inside your current direcotry.

sudo find -name itsubuntu.txt

4. Search for A File Ignoring Case

Run the following command to search for a file text.txt without the matching case which means that if there are two files by the name test.txt and Text.txt, it will display both files.

sudo find -iname test.txt

5. Search for Folders Inside the Current Directory

Run the following command to search for folders inside the current directory.

sudo find -type d

6. Search For A Specific Folder In a Directory

Run the following command to search a specific folder in a directory.

sudo find /home -type d -name users

This command will search for a folder called users inside the /home directory.

READ More Relevant Stuff:  15 Basic Cat Command Examples In Linux

7. Search All Symbolic Links

Run the following command to search all symbolic links.

sudo find /usr -type l

8. Find Files With 777 Permission

Run the following command to search the files with 777 permission.

sudo find -type f -perm 0777 -print

9. Find Files Without 777 Permissions

Find the files without 777 permissions with the help of command below.

sudo find / -type f ! -perm 777

10. Find A File And Remove It

Run the following command to find a specific command and remove it

sudo find -type f -name “test.txt” -exec rm -f {} \;

11. Find All Empty Files in The System

Run the following command to find the all empty files in the Linux

sudo find /tmp -type f -empty

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

    Your email address will not be published. Required fields are marked *