/etc/bash.bashrc issue

To make a long story short, /etc/bash.bashrc is, or was, the place to put universal aliases. But something isn’t working right now, and I’m not entirely sure why. I added some aliases that I’ve been using for years, including on other Manjaro systems, but now it doesn’t work. It stalls as if it’s doing something, then outputs “Segmentation fault” and quits the terminal. I have no idea what’s causing this, all I know is that if I CRTL+C and stop whatever it’s doing, it’ll stop and then when I remove the aliases, everything works fine again. Is /etc/bash.bashrc no longer the appropriate place for system-wide aliases anymore? Is there some sort of sourcing issue that I’m missing? Any help in this matter would be highly appreciated, as like most people using aliases, this makes my terminal life a lot easier.

Hi,

I always make a reference to .bash_aliases to store all them. Put the code in the local .bashrc of $USER and you’re done.
vim .bash_aliases and copy the aliases in it. Good luck.

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
1 Like

I’m sorry, I’m not sure I fully understand what you’ve written. If I put the aliases in the $USER .bashrc file, will all users be able to utilize the aliases? And from which file would I be referencing ~/.bash_aliases

in you’re local .bashrc you make the reference to a new file .bash_aliases
You nano vim or whatever editor you use to fill you’re .bash_aliases with the aliases you want. The reference i described put that in .bashrc of the user … that’s all.
If all users make use of the aliases you want you have to make the reference in /etc/bash.bashrc
Mandatory you will have to create a .bash_aliases for all users.

First you try this for the current user. If it works for you do the same for all user you want.

Like megavolt says perhaps there is a fault in one of the aliases.
an alias should always look like this with quotes ore one quote

alias reboot="systemctl reboot -i"

Show /etc/bash.bashrc pls ?

Then one of your alias has a problem? Most likely a command produces that.

That was my initial thought, but why is it just now an issue? I haven’t changed these aliases since 2021, and they’ve worked perfectly fine since. It wasn’t until this most recent install that it’s ever given me an issue at all. Did the syntax for using aliases change?

Because of a partial upgrade, a corrupt binary? It has nothing to do with the syntax, if you didn’t change it.

It could be those things, I have been having some package issues that I’m unsure of how to resolve. Regardless, doing it @stormschip’s way works. I don’t really like it, but it does work, so I guess I’ll just be doing that from now on. I’d like to thank you both for your time, though.

#
# /etc/bash.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

PS1='[\u@\h \W]\$ '

case ${TERM} in
  Eterm*|alacritty*|aterm*|foot*|gnome*|konsole*|kterm*|putty*|rxvt*|tmux*|xterm*)
    PROMPT_COMMAND+=('printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"')

    ;;
  screen*)
    PROMPT_COMMAND+=('printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"')
    ;;
esac

if [[ -r /usr/share/bash-completion/bash_completion ]]; then
  . /usr/share/bash-completion/bash_completion
fi

This is my /etc/bash.bashrc. On all other installs, I’ve just been able to append my aliases to the bottom and then source /etc/bash.bashrc to make them active.

Keep in mind putting them in /etc/bash.bashrc it is for all users.
Putting aliases in a different file means you can have different aliases for specific users. putting them in .bashrc of the user also works.

That’s what I was trying to do, and what I used to do. But for some reason, it doesn’t seem to work anymore. If I wrote

if [ -f /etc/bash.bashrc ]; then
/etc/bash.bashrc
fi

in ~/.bashrc, would it work?

Don’t it is default manjaro. If you make adjustments always do it for the local user.
look at ownerships and rights for /etc than you see why.
Before you make adjustments make copies / backups.

Yeah, it just screwed up again. Oh, well. The solution you gave me works fine enough, I’ll just have to get used to it. Again, thank you for your time.

It is also possible to use .bash_profile for the current user:

nano ~/.bash_profile

Aye, but aliases should not go into a *profile file. Those are for variables and functions. Aliases belong in an *rc file. At least, in good UNIX tradition, that is. :wink:

The rationale is that a *profile file is read only once, upon login, whereas the *rc file on the other hand is read every time a shell is started.

1 Like

You need to add source in front of /etc...

1 Like

Interesting. I’d not known of that distinction; apart from *profile being read first; or if I did, I’d forgotten.

It equates to the same, either way. :smile_cat:

1 Like

Doesn’t change the effect. Sorry.

You will need to log out and log back in first.

And yes, you do need to source it in order to load it into the current environment. Otherwise you will only be running it in a subshell, and upon exiting that subshell at the end of the file, nothing will have changed in your current environment.

Sorry, but it still doesn’t work. But I appreciate the input.