Where is the output of $ alias defined?

I would like to know, out of curiosity, where the default aliases are defined.

$ alias
alias +=‘pushd .’
alias – -=‘popd’
alias …=‘cd …’
alias …=‘cd …/…’
alias beep=‘echo -en “\007”’
alias cd…=‘cd …’
alias dir=‘ls -l’
alias dup=‘dup.sh’
alias egrep=‘egrep --color=auto’
alias ff=‘clear; fastfetch’
alias fgrep=‘fgrep --color=auto’
alias grep=‘grep --color=auto’
alias ip=‘ip --color=auto’
alias l=‘ls -lhFi’
alias la=‘ls -lahFi’
alias ll=‘ls -l’
alias ls=‘_ls’
alias ls-l=‘ls -l’
alias md=‘mkdir -p’
alias o=‘less’
alias rd=‘rmdir’
alias rehash=‘hash -r’
alias unmount=‘echo “Error: Try the command: umount” 1>&2; false’
alias you=‘if test “$EUID” = 0 ; then /sbin/yast2 online_update ; else su - -c “/sbin/yast2 online_update” ; fi’

I am aware that there are a few of my own in between there, which is even more confusing.
There are both 13 and 10 year old answers which are not applicable anymore.

I am just noticing that the ls command itself is aliased as _ls so I am assuming there’s a custom binary somewhere that is used instead.

Read man bash, search for the section INVOCATION and check the startup files that are mentioned there. Various packages may drop files in the directories processed by bash on startup and these files may define aliases.

Maybe this helps?

[jpv] @ [running-gecko] in [/etc/bash_completion.d]
$ PS4='+$BASH_SOURCE> ’ BASH_XTRACEFD=7 bash -xl 7> /tmp/mylog
Agent pid 28414
[jpv] @ [running-gecko] in [/etc/bash_completion.d]
$ grep "alias " /tmp/mylog | grep -e /home -e /etc
+++/usr/etc/profile.d/ls.bash> unalias ls
+++/usr/etc/profile.d/ls.bash> alias ls=_ls
+++/usr/etc/profile.d/ls.bash> alias ‘dir=ls -l’
+++/usr/etc/profile.d/ls.bash> alias ‘ll=ls -l’
+++/usr/etc/profile.d/ls.bash> alias ‘la=ls -la’
+++/usr/etc/profile.d/ls.bash> alias ‘l=ls -alF’
+++/usr/etc/profile.d/ls.bash> alias ‘ls-l=ls -l’
+++/usr/etc/profile.d/alias.bash> alias o=less
+++/usr/etc/profile.d/alias.bash> alias ‘…=cd …’
+++/usr/etc/profile.d/alias.bash> alias ‘…=cd …/…’
+++/usr/etc/profile.d/alias.bash> alias ‘cd…=cd …’
+++/usr/etc/profile.d/alias.bash> alias – ‘+=pushd .’
+++/usr/etc/profile.d/alias.bash> alias – -=popd
+++/usr/etc/profile.d/alias.bash> alias rd=rmdir
+++/usr/etc/profile.d/alias.bash> alias ‘egrep=egrep --color=auto’
+++/usr/etc/profile.d/alias.bash> alias ‘fgrep=fgrep --color=auto’
+++/usr/etc/profile.d/alias.bash> alias ‘grep=grep --color=auto’
+++/usr/etc/profile.d/alias.bash> alias ‘ip=ip --color=auto’
+++/usr/etc/profile.d/alias.bash> alias ‘md=mkdir -p’
+++/usr/etc/profile.d/alias.bash> alias ‘rehash=hash -r’
+++/usr/etc/profile.d/alias.bash> alias ‘you=if test “$EUID” = 0 ; then /sbin/yast2 online_update ; else su - -c “/sbin/yast2 online_update” ; fi’
+++/usr/etc/profile.d/alias.bash> alias ‘beep=echo -en “\007”’
+++/usr/etc/profile.d/alias.bash> alias ‘unmount=echo “Error: Try the command: umount” 1>&2; false’
++/home/jpv/.bashrc> alias ‘la=ls -lahFi’
++/home/jpv/.bashrc> alias ‘l=ls -lhFi’
++/home/jpv/.bashrc> alias ‘ff=clear; fastfetch’
++/home/jpv/.bashrc> alias dup=dup.sh

Very well! Thank you! There are a bunch of other config files in /usr/etc! I had no idea!

1 Like

To get back to your comment also: That’s actually a perfectly reasonable answer. I would have taken time tomorrow to trace all the files that would be source. Would’ve taken some time to go through all the bash that’s in those to figure out where I need to look to find them. But, alas, a to my eyes at least, somewhat cryptic two liner did the job, see below!