I wholeheartedly agree with this blog post. I believe someone on here yesterday was asking about config file locations and setting them manually. This is in the same vein. I can’t tell you how many times a command line method for discovering the location of a config file would have saved me 30 minutes of googling.

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.

If it’s not in /etc it should be in the directory the exe file is located.

Atemu
link
fedilink
41Y

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.

Well good because a program shouldn’t be writing to its config file either.

~/.config is the non-root version of /etc these days. But you just have to know that, which isn’t ideal.

otoh, unix directory structure is far from black magic once you know it. I have yet to see an OS that does it that elegantly (leaving aside systemd)

@Jummit@lemmy.one
link
fedilink
9
edit-2
1Y

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

@teawrecks@sopuli.xyz
link
fedilink
7
edit-2
1Y

~/.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.

Configuration for root is in /root/, that is, root’s home directory. /etc is for system configuration, different thing.

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

(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.

bionade24
link
fedilink
41Y

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.

elmicha
link
fedilink
91Y

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.

andrew
link
fedilink
21Y

There’s also a nice version in perftools that can be given a PID. https://github.com/brendangregg/perf-tools/blob/master/opensnoop

bionade24
link
fedilink
21Y

You still don’t know which location is preffered and how get they get merged. In my experience, digging into the source is the most straighforward. But my usual problem is more that the config option doesn’t do at all what the documentation says it does.

FermatsLastAccount
link
fedilink
1
edit-2
1Y

Wouldn’t the strace.out file be in chronological order?

Yes, though if two different files allow for the same config key - you’re stuck opening both to check

bionade24
link
fedilink
11Y

And you still couldn’t be sure, could be parsed the other way around for historic reasons.
Just reading the source code (if possible ofc) is imho easier than reading.

True, though I had to use strace method on closed source binaries before (zoom)

I was digging through the comments for exactly this, thanks!

techno156
link
fedilink
31Y

Unless it’s using the Registry for some config values.

True. That’s harder to track down.

fartsinger
link
fedilink
11Y

Procmon if you’re a masochist, or do a before and after snapshot. Here’s one tool for the latter: https://www.nirsoft.net/utils/registry_changes_view.html

exscape
link
fedilink
4
edit-2
1Y

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.

SFaulken
link
fedilink
301Y

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.

which is not config files. ~/.local is just user specific override for /usr

I’d take it a step further and say that all programs should be completely self-contained in one folder.

araquen
link
fedilink
171Y

This is the big thing I miss from my “pre-Unix” Mac days. In OS9 and earlier, apps were self contained, and didn’t spread their garbage everywhere. You deleted an app, you deleted all the app. Granted, there was a tradeoff (the parade of conflicting control panels and extensions you had to manually diagnose when your machine went sideways) but I never understood why in the Windows and Linux worlds devs would code so sloppily. Who told that dev my Documents folder is where their nonsense needs to go? That Documents folder is for my use, not theirs.

Still salty after all these years

I use linux and this annoys me to, every program just spams my home directory with config files, even though .config and .cache exist and are the standard

Run ls -al | wc -l to see the mess. If you can get it below 25, you have a clean setup.

@Dohnakun@lemmy.fmhy.ml
bot account
link
fedilink
31Y

Set XDG_CONFIG_HOME=<path> in your environment and most tools follow it

I have, unfortunatly a lot of programs dont.

@Dohnakun@lemmy.fmhy.ml
bot account
link
fedilink
11Y

Right, forgot. And the specific workaround.

brie
link
fedilink
31Y

Programming tools/IDEs seem especially egregious.

.android
.cargo
.choosenim
.conda
.emacs.d
.nimble
.npm
.rustup

Who told that dev my Documents folder is where their nonsense needs to go? That Documents folder is for my use, not theirs.

Microsoft did for a while. 😜

@itchychips@lemmy.ml
link
fedilink
English
11Y

There are so many places that games decide to put their save files on Windows.

I’ve got save directories in:

  • %HOMEDRIVE%%HOMEPATH%\Saved Games (only Elite Dangerous)
  • Documents (Mass Effect Andromeda, X4: Foundations, EVE Online, GreedFall, Wo Long: Fallen Dynasty, SteamVR)
  • Documents\My Games
  • %APPDATA%
  • %LOCALAPPDATA%
  • %APPDATA%..\LocalLow (does not seem to have an environment variable defined for this one)
  • Various game install directories

There’s probably other places. Not sure how much the registry is used for saves, either, but that would complicate backups more than they already are.

I’d love if they just unify save and config data for games to %APPDATA%. Documents should never be touched by software without the user’s explicit consent, though, and because of the situation, the Documents directory is the last place I ever put actual documents.

@TheBaldness
No. Static libraries are a security risk.
@wet_lettuce

The Baldness
link
fedilink
11Y

Isn’t this what updates are for? maybe I’m misunderstanding what you mean by static libraries.

@TheBaldness
When you bundle everything for an app inside a self-contained directory, it’s no different than static linking a binary.

An exploit in a library the package links against means that application is still vulnerable even if the same library on the operating system has been updated to fix the security flaw.

The Baldness
link
fedilink
11Y

Apple managed to do it for a long time. I imagine they update the app more frequently than they would otherwise.

@TheBaldness
For apps that Apple controls that may be fine, but most people do not get their apps from a single vendor and not all vendors are fast at pushing updates.

stom
link
fedilink
241Y

That doesn’t work well for… well, most software I can think of.

Games: I do not want to backup the entire folder to ensure I have my save files. Modern games are huge. I want my saves to be located somewhere easy to get to (for the average user) and be quick to backup, without having to go in and cherry-pick specific files.
There was a good trend of using Documents/My Games, but sadly that seems to have fractured and now there’s also Saved Games, savegames, and some software has moved to using %appdata% or just storing saves in the game install location. There’s no consistency, it’s a real pain in the hole.

DCC software (Blender, Photoshop, whatever): user preferences and config files. Again, I idon’t want to backup the entire software, as I’m likely to reinstall it from an official source when migraing/reinstalling to ensure I have the latest updates. However I do want to be able to backup my preferences or plugins easily.

Any software that allows users to customise it: let me backup those preferences without cloning the entire app.

I do wish there was a standardised folder struture for user data, but it’s 2023 and the chances of getting Windows/Max/Nix to agree upon and comform to a generic structure as sadly. The only thing I can think of that’s the same across platforms is the .ssh folder.

@ursakhiin@beehaw.org
link
fedilink
3
edit-2
1Y

The different OSes generally have a prescription for where to put things. Windows is a stickler about Program Files and the only thing that should exist there is install content.

My Games and Saved Games is a remnant of times past when they were trying to figure out where to put that stuff. Generally, %Appdata% is where they recommend storing config and files that your application may mutate over time. e.g save files or logs

They just decided it didn’t make sense to break that stuff up and not every application dev has caught up to that.

For Mac, the /Library/Application \Support directory is where config files should live. Though some apps support /Users/<user>/.config for account level configs.

For Linux, as others have pointed out, /etc for global config or /home/<user>/.config for account level config.

The frustration about not knowing where to find things either comes from not knowing the standards or developers not following them. (Or Microsoft changing them every 2 versions)

Edit: Mac uses Users not home.

stom
link
fedilink
11Y

Yep. My main gripe is that due to various developers not catching up with new standards, a users files can be scattered all over the place.

I appreciate that - in theory - %appdata% should contain just a users files, but a number of apps also use it to store program data leading to a huge folder size. My own is >100GB, with some of the largest offenders being python and node dependencies that are not specific to myself, and could really be cached somewhere else.

deleted by creator

Doh, you’re of course correct. Thanks! It’s fixed

What if they stored the literal files under the installation folder but then linked them under other folders classed as either Saves/configs/creations.

In theory we just need to standardize those few classifications and people could decide where that type of files can be found, always under a folder of the name of the program.

I feel with modern computing it doesn’t really make sense to only find certain files in a single location. The structure you use to create and save digital art may be wholy different from the one you use to browse/show/upload your art. I like to have all my game installations easily accessible for modding but i hate if i had to to use it to launch a game trough the exe. In a way other software may already cater to this need but its often bloated and far from standardized.

While were at it allow people to set a display name for program what they like during installations and if i want to install sm multiple times, why not allow it. the os just remembers what there actually called if other software looks for it, in case of multiple it could ask which one to use.

Of course i can dream what i want, creating new standards is probably one of the hardest thing to agree on and get done.

TehPers
link
fedilink
61Y

I don’t think Win/Mac/*nix need to use the same structure across different OSs, but it would be nice if applications used conventional paths for within each of those OSs.

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.

read the man page

this is not really what the article is about.

yes you can read man page, you can find there all possible locations of config files. yet you still don’t know where config file is stored. you have to check all the possible locations.

also if there would be some standard so you can query app for its config files, you could make automated backups easily. at least much easier that now.

of course I understand this is completely unrealistic, in software world everyone will do whatever they want…

The good ol’ RTFM

For real. Usually the config file locations is at the bottom, so jumping to it is quick.

@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.

exu
link
fedilink
41Y

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.

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.

This is the way.

I doubt that’s a linux problem. All apps store config in /etc, ~/.*rc or ~/.config

Everything else should be considered a bug (looking at you, systemd!)

Check out the Lemmy install docs

well, lemmy is a webapp.

Those usually store config in some www/htdocs/config dir. Lemmy does aswell and offers LEMMY_CONFIG_LOCATION to override.

@Dohnakun@lemmy.fmhy.ml
bot account
link
fedilink
14
edit-2
1Y

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?

Leirda
link
fedilink
21Y

You can call it recursively on .config (for instance), and watch for specific events (creation, deletion, modification, etc). But I expect this to be expensive on really large folders and I’d avoid it if I could.

Btw it’s syscalls iirc (inotify-tools just exposes them)

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.

Xeelee
link
fedilink
8
edit-2
1Y

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)

It puts it’s Configs in /etc/ or it gets the hose again.

@Sharmat@beehaw.org
link
fedilink
English
141Y

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.

GoboLinux kind of solved that problem but it hasn’t been updated in years.

take a look at NixOS

@Sharmat@beehaw.org
link
fedilink
English
2
edit-2
1Y

Does the nix configuration file contain also the config files of the programs within it?

@acow@beehaw.org
link
fedilink
English
11Y

Mixed. Many folks use home-manager to configure their user environment with nix, and you can specify config files there. However, escape hatches to use regular files not managed by nix exist to make config tweaking faster. You can specify your config file contents in nix, which works well for server deployments, but for desktop use it usually ends up being a mix of seldom-changed config going in the nix definitions, and other things that, say, revolve around GUI tools for config tweaking (eg KDE apps) continuing to do their own thing.

I haven’t met one person who doesn’t use home-manager. Maybe that’s because most people I talk to use tiling window managers and stuff like that, where you define everything in text files.

You can see my config at https://github.com/n3oney/nixus.

PC, Laptop and aarch64 server configured in one place with shared components

Danacus
link
fedilink
English
211Y

Like $XDG_CONFIG_HOME and $XDG_DATA_HOME?

@ddnomad@infosec.pub
link
fedilink
English
171Y

Sadly, what we seem to have over and over is https://xkcd.com/927/

It’s getting better though

eleanor
link
fedilink
English
41Y

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.

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 huge if a distro like Fedora did that

And also: where it found the config file it is actually using at the moment. This would cover the 90% of the cases in which you just want to change a single Key to a different value or something or so…

Create a post

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.

  • 1 user online
  • 56 users / day
  • 167 users / week
  • 618 users / month
  • 2.31K users / 6 months
  • 1 subscriber
  • 3.28K Posts
  • 67K Comments
  • Modlog