Sudo doesnt retain settings of ~/.config

Whenever I run any command line tools without sudo, they take the settings as in ~/.config and work fine. But whenever I run the same CLI tools with same parameters but with sudo, it falls back to default setting. How can I make this behavior consistent?

5 points · 4 comments · view on lemmy.world

4 Comments

toyvo@programming.dev · 6 pts · 1y

Generally define the same config options for the root user in /root/.config

JohnnyMac@lemmy.world · 6 pts · 1y (3 replies)
[ removed ]
clot27@lemm.ee · 1 pts · 1y (2 replies)

Thanks for the heads up! I will try the given solutions.

but that doesn't do anything with ~/.config

What do you exactly mean by this?

JohnnyMac@lemmy.world · 3 pts · 1y
[ removed ]
MadhuGururajan@programming.dev · 2 pts · 1y

The letter ~ (tilde) is relative to the current user. When you use sudo, you become root. So ~ points to /root. Whereas if you are not using sudo then ~ points to /home/yourname

sudo@programming.dev · 5 pts · 1y

I run commands as the root user so I use the root users configs. Usually that's in /root/.config/ but it might be different in NixOS.

You'll have to either copy your configs over to the root users config dirs. I highly recommend auditing what you copy though for security.