How Can I Find a Specific Config File in Linux?

June 13, 2025 5 answers
Asked by TechieTurtle92
I'm on a quest to find a configuration file that fits these requirements: it was created or modified after March 3, 2020, is between 25KB and 28KB in size, and likely has a .conf or .cfg extension. I've tried using this command: `find / -type f ( -name '*.conf' -o -name '*.cfg' ) -size +25k -size -28k -newermt 2020-03-03 2>/dev/null`, but I'm not sure if it's the best approach. I have a few specific questions: 1. Are there common places besides /etc where these config files might be found? 2. Should I use -cnewer instead of -newermt? 3. How can I adjust my search to check file permissions as well?

Answers

CommandNinja47
If you want a different approach, consider using `mlocate`, which is usually on most systems. It keeps a database of files, speeding up your searches. You can run: `locate --regex '.(conf|cfg)$' | xargs stat --format "%n;%s;%Y"` to get a list formatted with the file name, size, and last modification time. From there, you can filter the output with `awk` to find files matching your size and modification date.
Reply to this answer
FileFinder99
To start, you should specify the mount points of relevant filesystems and use -xdev to avoid searching through irrelevant areas like /tmp or /proc. Typically, configuration files are located under /etc, but they could also be in unusual directories based on software installations. If your command is running under a non-root user, you may not have permission to access some files, so running it as root might be necessary to find everything you need.
Reply to this answer
PracticalPathfinder
Is this search for a niche exercise, or could practical knowledge about typical config file locations simplify your quest? Sometimes itโ€™s easier to find where a file should be than to sift through every directory.
Reply to this answer
ScriptMaster3000
Make sure to run your commands as root to access every directory. This way, nothing is off-limits, and you'll have a much better chance of finding that elusive config file.
Reply to this answer
ConfigExplorer88
What application or service is this config file for? Knowing the specific software can guide you to likely locations where its configuration files reside. Also, what led you to search everywhere if you can't recall the specific location? It might help to narrow down your search.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions