I am having a hard time with root
whenever i run sudo su
and then nano ~/.zshrc
, edit my file to add PATHs followed by a source ~/.zshrc
, it works just fine.
That until i run sudo su myuser
to go back to my default user.
When i do that all my previous settings on root
are undone, and if i go back and check ~/.zshrc
it has no PATHs configured and doesnt work as intented.
Does anyone know why this happens? And how to fix it?
The problem you're having, is that ~
resolves to the home directory for the current user. So when logged in as root, ~
points to root's home directory (usually at /root
), whereas for myuser, ~
points at myuser's home directory (usually /home/myuser
), so you're actually editing different files.