Start your application / program with “strace” and see all the files it opens.
Also run “lsof” on a running process to see what files it has open.
A nice place to discuss rumors, happenings, innovations, and challenges in the technology sphere. We also welcome discussions on the intersections of technology and society. If it’s technological news or discussion of technology, it probably belongs here.
Remember the overriding ethos on Beehaw: Be(e) Nice. Each user you encounter here is a person, and should be treated with kindness (even if they’re wrong, or use a Linux distro you don’t like). Personal attacks will not be tolerated.
Subcommunities on Beehaw:
This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.
Start your application / program with “strace” and see all the files it opens.
Also run “lsof” on a running process to see what files it has open.
Or use inotifywait from inotify-tools. It logs acces <type> to specified file/folder.
Interesting. I have not heard of this tools. But you say specified file or folder, that means you already know the file location?
This is the way.
What's imho worse is how often config options or command flags don't actually do at all what's described in the manpage. I then have to dig into the source code once again and since you have to read through the whole behaviour it takes much longer than just looking up where the program tries to read config files.
Please - if you find such wrong docs in Open source software, submit a fix to the doc. It's as important as normal bugfixes.
I mean, that's sort of what xdg is intended to accomplish, with making $HOME/.config be the place, but it's kind of up to the individual software developers to comply. (Yes, I know, this doesn't really apply to Windows/Mac OS) But yeah, it would really be nice if configs/config locations were even remotely standardized.
There's also $HOME/.local/share for 'static data files' as part of XDG.
What I find more frustrating is undocumented environment variables to override config locations.
The amount of times I've had to dig through the source code for a CLI to find an environment variable to force the config somewhere should be zero. But it's not.
This drives me freaking bonkers. A lot of times libraries tend not to expose the env var to discourage its usage but IF YOU MADE IT IN THE FIRST PLACE YOU HAD A USE CASE FOR IT.
I guess the difficulty here is that sometimes that decision is made by the package manager, not the developer. You'll see Debian distros using a different location compared to a red hat one, while Mac OS is again different, so it might be hard for a developer to tell you where it is.
Still, some kind of universal CLI flag that tells you where the binary/service looks for configuration would be a great idea.
For Linux distros everything should use XDG_CONFIG_HOME
and distros should start refusing to package anything that doesn't.
It would be amazing yeah, standardising all user config files in the $HOME, and maybe etc/ or an default, non usable, user profile to store the original versions, in case of a bad config or corrupted file would save so much time debugging stuff.
Like $XDG_CONFIG_HOME
and $XDG_DATA_HOME
?
The XDG Base Directory standard has kinda sorta been doing that; and I like it. Not everything supports it; and it's not perfect, but at least it's better than the wild west that application configs used to be.
GoboLinux kind of solved that problem but it hasn't been updated in years.
And even if the program doesn't use config files (like various gnome, xfce and other programs), it should be possible to programmatically export and import full or partial configurations.
Seriously, I've lost so muuuuch time just trying to find where some random program decides to store its config files. It sometimes takes me more time than actually "doing the config"
Fortunately half of apps use dconf nowadays
With Synaptic, you can show all files associated with a package. That includes config files. Saved me a lot of hassle on numerous occasions.
Yeah anything installed via a package manager, like an rpm or deb package, you can query to see what files belong to that package. Problem is they often have default config file locations, like in your home dir, where they will not ship and install files. (Though they might create them as part of a post install process)
I don't know if you mean on linux but in my experience I have found the bottom part of the first man page usually has a section on config file locations.
It puts it's Configs in /etc/ or it gets the hose again.
(Windows) Resource Monitor, disk tab, tick the process, see what files it opens and closes.
Also the usual %programdata% and the two %appdata% find most things.
Do things stay in that list when they are not used (since they would be opened and closed in far less than a second)? If so that's pretty cool.
If not, you can use Process Monitor to check this. That's what I usually do.
The *nix equivalent is the lsof
command. This doesn't help you finding out in which hierarchy config files are parsed when the program accesses multiple ones, which is often the case.
You can use something like strace -eopen -f -o strace.out the_program
to find all files that the program tried or succeeded to open. Then you can try to find the config file(s) in strace.out.
There's also a nice version in perftools that can be given a PID. https://github.com/brendangregg/perf-tools/blob/master/opensnoop
@wet_lettuce
Should be /etc or /usr/local/etc or /opt/etc or /opt/vendor/product/etc or ~/etc.
With some exceptions for historic compatibility (like ~/.bashrc)
The man page should specify where.
The exceptions should only apply for cases where XDG is not available. In any other case, the appropriate XDG directoy configured by the user should be used first.
For user-specific config files, aren't they all supposed to be in ~/.config
these days? I've never heard of software using ~/etc
.
If it's not in /etc it should be in the directory the exe file is located.
~/.config
is the non-root version of /etc
these days. But you just have to know that, which isn't ideal.
If you are a developer, please take a look at the XDG Base Directory Specification and try to follow it, users will be very grateful.
Short summary:
Look for $XDG_CONFIG_HOME
for configs and $XDG_STATE_HOME
for state. If they aren't available, use the defaults (./config
and .local/share
).
But what about .local/, or .appname/? It's just a mess
~/.local
is the non-root version of /usr
. By .appname
do you just mean a folder that a specific app made in your home for itself? Yeah, I never condone that. imo that's just a badly behaving app. It should move that folder into ~/.config
.
Certainly not. Nothing should write to /usr/bin except for the package manager in FHS distros and some distros binary directories aren't writable at all.
obligitory windows user here to say that not only should every program should tell you where they are, but should also use them, or have a way to import configs via the command line. very frustrating to discover powershell automation is impossible for a program because ~~i am too lazy/stupid to figure out how to automate the gui~~ it doesn't have any way to modify configs without navigating the gui, cough cough winaero tweaker but this is only because i am an windows user, and i stubbornly refuse to learn how to use linux until absolutely necessary.
I think this is a drawback of not having more specialized communities in beehaw yet - I'm not sure if this advice is very niche advice or if it has some value in general awareness for the layperson?
Normally I'd look up and see "r/DevChat" or some such distinct community name and have immediate context of, "that's not really for you to figure out". But this is essentially "r/technology" so I'm left wondering if I personally can take anything of value from this post.
Not a criticism or complaint, just an observation.