Table of Contents
Finding Files
Apr 2020
Updated Apr 2023
Overview
One thing I have always struggled with is finding things in CentOS. So here I am going to put a few examples, and over time hopefully add some more.
If you are not 'root' then you can't search for any file/folder that requires root privileges.
Examples
To find a file, use: find / -file “install.sh”
I think -file should be - name: find / -name “install.sh”
In the above example, the “/” is root, so find will look in root and all of its subfolders for a file called “install.sh”.
You can specify a location to search with find /home “filename.ext”
If you are unsure about the filename, but can remember some of it, a wildcard search might help: find / -name “myFile*”
Find files with the same extension: find / -name *.log
If you only wish to find folders then use -type d: find / name home -type d
If you are only interested in files created in the last 2 days use: find / -name home -type d -mtime -2 This looks for folders called home created in the last 2 days.