One can create a file named .bash_aliases in their home directory to create aliases for that user.

Is there a way to create a .bash_aliases that is system wide for all users? I know one can add aliases in the /etc/bash.bashrc file but this is not ideal.

And is there a way to achieve this with other shells such as zsh and fish?

  • bzLem0n@lemmy.ca
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    1 year ago

    You should put the aliases in /etc/profile or create a file in /etc/profile.d/ for them. Most modern shells will source /etc/profile which in turn sources the files in /etc/profile.d/, so that’s the best spot for things like aliases for all users. See the Arch Wiki page Command-line shell, specifically sections 4 and 5.

    • trymeout@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      I put a myaliases.sh file in /etc/profile.d/ with all of my aliases and they do not show up in the terminal even after I rebooted my computer.

      • bzLem0n@lemmy.ca
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        1 year ago

        Did you make sure it is a bash script, starting with a shebang, and is executable.