I want to change the location of .xinitrc, .zshrc and .zshenv to ~/.config/x/xinitrc, ~/.config/zsh/zshrc and ~/.config/zsh/zshenv, but without simlinking them.

How can I achieve this? Do I have to change files that source these configuration files in /etc? Thank you in advance!

2 Answers 2


Both xinit and zsh can be told where to find their respective rc files with environment variables: XINITRC for xinit and ZDOTDIR for zsh (for the directory where to find .zshrc, .zshenv, .zlogin, .zlogout, .zcompdump...).

So you could try and seed the environment with those upon login.

For instance, if using a GNU/Linux distribution and the pam_env env modules, you could have:

XINITRC         DEFAULT=@{HOME}/.config/x/xinitrc
ZDOTDIR         DEFAULT=@{HOME}/.config/zsh

in /etc/security/pam_env.conf



In your ~/.pam_environment (see the pam_env man page for how to change the path of that one as well).


i think you don't like my way , but i think is useful

$ cat ~/.xinitrc

source ~/.config/x/xinitrc
$ cat ~/.zshrc

source ~/.config/zsh/zshrc

this methode is keeping your configs in any directory without using symlink

  • Why would this method be preferred over a symlink?
    – Brandon
    Commented Nov 8, 2021 at 3:52
  • 1
    if use git with a symlink or some backup something does not work
    – nextloop
    Commented Nov 8, 2021 at 18:43

You must log in to answer this question.