How to find a file in the Linux terminal?
Tagged: linux
- AuthorPosts
- August 29, 2020 at 4:01 AM #3699Santhosh Kumar DKeymaster@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 withsudo
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 theiname
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 thefind
command as follows.sudo find / -name filename1.pdf
For instance, to list all files with the extension
.pdf
, you can use thefind
command as follows.sudo find / -type f -name "*.pdf"
Learn more Linux commands.
August 29, 2020 at 6:05 AM #3764Santhosh Kumar DKeymaster@santhoshTyping the
find
command followed by a period.
separated by a space lists all files in the current directory.find .
- AuthorPosts
- You must be logged in to reply to this topic.