How Can I Find a Specific Config File in Linux?

0
0
Asked By TechieTurtle92 On

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

Answered By ScriptMaster3000 On

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.

Answered By PracticalPathfinder On

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.

Answered By FileFinder99 On

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.

Answered By CommandNinja47 On

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.