Page 1 of 1

aliases exist but .bash_aliases doesnt exist - SOLVED

Posted: Sun Sep 16, 2018 12:27 am
by bill_steamshovel
Am getting adventurous and would like to dabble with shellscripts and aliases.

Typing in alias yields the following, (I assume they were hard wired into the installation files)

bill@Bill-Linux ~ $ alias
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'

where are they kept please ? .bash_aliases or a .bashrc and .bash_profiles file are discussed in my various google searches - do I need to make one in my home directory to store my own aliases or do I tag them onto the end of wherever the above aliases are kept ?

I eventually found a file called bash.bashrc file in the etc directory - am now getting a tadge confused - do I append my aliases to this file ?

- just point me to a good web page please ? - think I must have confused myself whilst googling this stuff.

inxi _Fxzd and bashrc are attached

Bill

Re: aliases exist but .bash_aliases doesnt exist

Posted: Sun Sep 16, 2018 12:34 am
by catweazel
bill_steamshovel wrote:
Sun Sep 16, 2018 12:27 am
where are they kept please ?
.bashrc
bill_steamshovel wrote:do I append my aliases to this file ?
Yes.

Code: Select all

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

Re: aliases exist but .bash_aliases doesnt exist

Posted: Sun Sep 16, 2018 1:40 am
by smurphos
Don't edit /etc/bash.bashrc - it's the master copy used for setting up new user accounts. You will have a local copy in your home folder ~/.bashrc which is the one you can add your aliases to.

Re: aliases exist but .bash_aliases doesnt exist

Posted: Sun Sep 16, 2018 7:38 am
by bill_steamshovel
Thanks for the replies gents.

Thanks for your help.

Had another look and found the .bashrc in ~/ ............. must have been looking with my eyes shut the first time.

Puzzling thing is that those aliases are not in that file, will see if I can find where they are.

Off to write some aliases

Bill

Re: aliases exist but .bash_aliases doesnt exist

Posted: Sun Sep 16, 2018 7:43 am
by gm10
smurphos wrote:
Sun Sep 16, 2018 1:40 am
Don't edit /etc/bash.bashrc - it's the master copy used for setting up new user accounts. You will have a local copy in your home folder ~/.bashrc which is the one you can add your aliases to.
No, it's not, it's the system-wide bashrc that gets run before your user version does. The files that get used for user profiles are in /etc/skel
bill_steamshovel wrote:
Sun Sep 16, 2018 7:38 am
Puzzling thing is that those aliases are not in that file, will see if I can find where they are.
They are in /etc/bash.bash_aliases

You can also set up your own ~/.bash_aliases - personally I find that cleaner than sticking them into ~/.bashrc, but it comes down to preference, there's no functional difference.

Aliases working Thankyou

Posted: Sun Sep 16, 2018 8:51 am
by bill_steamshovel
Hey,

Well done everybody .....

Aliases now working - using .bash_aliases ....... it is easier to read my simple stuff here than it is to append it to .bashrc with all the gobbledygook at the top.

My favourite one is up=cd ..

....... and then I can use the up arrow to keep going up one directory at a time - trivial yet quite pleasing.

Off to have a go at shellscripts now -

Bill

Re: Aliases working Thankyou

Posted: Sun Sep 16, 2018 9:17 am
by gm10
bill_steamshovel wrote:
Sun Sep 16, 2018 8:51 am
My favourite one is up=cd ..
Looking through my list, the most important one is clearly:

Code: Select all

alias rot13='tr '\''A-Za-z'\'' '\''N-ZA-Mn-za-m'\'''
:lol:

Re: aliases exist but .bash_aliases doesnt exist - SOLVED

Posted: Mon Sep 17, 2018 7:08 am
by bill_steamshovel
Wasn't game to try rot13 but I did look up man tr to try and understand it..... ummmmm ..... interesting. :D

Re: aliases exist but .bash_aliases doesnt exist - SOLVED

Posted: Mon Sep 17, 2018 7:16 am
by gm10
tr is just a tool for character substitution in an input stream, and ROT13 is a substitution cipher, so it's the obvious tool to use (among many other possible choices).

And I was obviously joking about ROT13 being important but if you want to understand: https://en.wikipedia.org/wiki/ROT13