How to find a file in the Linux terminal?
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Tagged: linux
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.
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.
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.
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.
Typing the find
command followed by a period .
separated by a space lists all files in the current directory.
find .