this post was submitted on 25 Jun 2023
664 points (100.0% liked)

Technology

37712 readers
174 users here now

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.

founded 2 years ago
MODERATORS
 

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.

top 50 comments
sorted by: hot top controversial new old
[–] KIM_JONG_JUICEBOX@beehaw.org 31 points 1 year ago (3 children)

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.

[–] Dohnakun@lemmy.fmhy.ml 12 points 1 year ago* (last edited 1 year ago) (1 children)

Or use inotifywait from inotify-tools. It logs acces to specified file/folder.

[–] KIM_JONG_JUICEBOX@beehaw.org 4 points 1 year ago (1 children)

Interesting. I have not heard of this tools. But you say specified file or folder, that means you already know the file location?

[–] leirda@lemm.ee 2 points 1 year ago

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)

[–] Smk@lemmy.ca 7 points 1 year ago

This is the way.

[–] heeplr@feddit.de 2 points 1 year ago (1 children)

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!)

[–] KIM_JONG_JUICEBOX@beehaw.org 1 points 1 year ago (1 children)

Check out the Lemmy install docs

[–] heeplr@feddit.de 2 points 1 year ago

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.

[–] SFaulken@kbin.social 26 points 1 year ago (1 children)

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.

[–] TheElectroness@beehaw.org 5 points 1 year ago (1 children)

There's also $HOME/.local/share for 'static data files' as part of XDG.

[–] heeplr@feddit.de 2 points 1 year ago

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

[–] bionade24@kbin.social 24 points 1 year ago

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.

[–] darkevilmac@kbin.social 19 points 1 year ago (2 children)

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.

[–] ursakhiin@beehaw.org 2 points 1 year ago

I genuinely do not like apps using environment variables for config if they aren't running in their own contained environment. It makes me uncomfortable.

[–] detectivemittens@beehaw.org 2 points 1 year ago

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.

[–] jonne@infosec.pub 15 points 1 year ago (1 children)

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.

[–] Rexelpitlum@discuss.tchncs.de 5 points 1 year ago

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

[–] Sharmat@beehaw.org 11 points 1 year ago (3 children)

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.

[–] daan@lemmy.vanoverloop.xyz 22 points 1 year ago (1 children)

Like $XDG_CONFIG_HOME and $XDG_DATA_HOME?

[–] ddnomad@infosec.pub 14 points 1 year ago

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

It’s getting better though

[–] BarrierWithAshes@kbin.social 5 points 1 year ago (1 children)

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

[–] neoney@lemmy.neoney.dev 3 points 1 year ago (1 children)
[–] Sharmat@beehaw.org 2 points 1 year ago* (last edited 1 year ago) (2 children)

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

[–] acow@beehaw.org 1 points 1 year ago (1 children)

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.

[–] neoney@lemmy.neoney.dev 1 points 1 year ago

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

load more comments (1 replies)
[–] exu@feditown.com 8 points 1 year ago

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.

[–] Xeelee@kbin.social 8 points 1 year ago* (last edited 1 year ago) (1 children)

With Synaptic, you can show all files associated with a package. That includes config files. Saved me a lot of hassle on numerous occasions.

[–] KIM_JONG_JUICEBOX@beehaw.org 3 points 1 year ago

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)

[–] bren42069@thelemmy.club 8 points 1 year ago (3 children)
[–] xavier666@lemm.ee 3 points 1 year ago

The good ol' RTFM

[–] uyuu@lemmy.4d2.org 1 points 1 year ago

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

[–] aacid@beehaw.org 1 points 1 year ago

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

[–] WildfireFailure@programming.dev 7 points 1 year ago (2 children)

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

[–] teawrecks@sopuli.xyz 10 points 1 year ago (3 children)

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

[–] Jummit@lemmy.one 10 points 1 year ago* (last edited 1 year ago)

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

[–] SubArcticTundra@lemmy.ml 5 points 1 year ago* (last edited 1 year ago) (1 children)

But what about .local/, or .appname/? It's just a mess

[–] teawrecks@sopuli.xyz 6 points 1 year ago* (last edited 1 year ago)

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

[–] barsoap@lemm.ee 2 points 1 year ago

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

[–] Atemu@lemmy.ml 4 points 1 year ago (1 children)

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.

[–] intensely_human@lemm.ee 1 points 1 year ago

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

[–] SocialJusticeHeals@mastodon.social 7 points 1 year ago (2 children)

@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@feditown.com 6 points 1 year ago

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.

[–] dan@upvote.au 4 points 1 year ago

For user-specific config files, aren't they all supposed to be in ~/.config these days? I've never heard of software using ~/etc.

[–] eclipse@beehaw.org 6 points 1 year ago (1 children)

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"

[–] SubArcticTundra@lemmy.ml 3 points 1 year ago

Fortunately half of apps use dconf nowadays

[–] Atarian@vlemmy.net 5 points 1 year ago

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

[–] Snapz@beehaw.org 3 points 1 year ago

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.

[–] ValiantHobo@discuss.tchncs.de 2 points 1 year ago

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.

load more comments
view more: next ›