How to find a file in the Linux terminal?

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3699
    Santhosh Kumar D
    Keymaster
    @santhosh

    To find a file in the Linux terminal, you need to use the find command. You need to tell it where to search and what file to search for. You can search for files by name, type, group, owner, date, permissions, and other criteria.

    How to find a file in the Linux terminal?

    You can search for a file in any directory from any directory. When you open the Linux terminal, you will begin from the root directory. When you are searching from the home directory, you will need to prefix the find command with sudo in-order to have root privileges.

    How to find a file by its name?

    For instance, you can use the following command to find all files named filename1.

    sudo find / -name filename1

    Note: Linux is very particular about case. You can use name for case-sensitive or the iname for case-insensitive.

    How to find a file by its type?

    For instance, to find all files with the name and extension filename1.pdf, you can use the find command as follows.

    sudo find / -name filename1.pdf

    For instance, to list all files with the extension .pdf, you can use the find command as follows.

    sudo find / -type f -name "*.pdf"

    Learn more Linux commands.

    #3764
    Santhosh Kumar D
    Keymaster
    @santhosh

    Typing the find command followed by a period . separated by a space lists all files in the current directory.

    find .
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.