Where to add custom aliases?

I have added my own custom aliases to this file:

$HOME/.bash_aliases

However, from time to time the file gets overwritten by openhabian self updates. Can I create my own “custom” .bash_aliases?

Does .bash_rc or .profile get overwritten too?

I don’t know. I didn’t even know I could store my aliases in these two files. Will try that and post the results.

It’s been a long time since I’ve used Bash, but I believe both also get sourced when you log in.

ok. maybe there is another way for achieving my goal as I am no expert in Linux…
All I want to do is to type in shortcuts for the following commands.
And entering them into the aliases file seemed to be an easy way.

alias ohconsole="sudo openhab-cli console"
alias ohconfig="sudo openhabian-config"
alias ohbackup="sudo $OPENHAB_RUNTIME/bin/backup"
alias ohrestart="sudo /bin/systemctl restart openhab.service"
alias ohstop="sudo /bin/systemctl stop openhab.service"
alias ohstart="sudo /bin/systemctl start openhab.service"
alias pioff="sudo systemctl poweroff"
alias pirestart="sudo systemctl reboot"
alias logrestart="sudo /bin/systemctl restart frontail.service"

See Shell initialization files for all the Bash init files and what they are for. It also shows how they are loaded in what order. You’ve lots of options. You just need to find one that isn’t overwritten by openHABian.

1 Like