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?
4 Answers
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.
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.
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.
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.
Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures