This is my alias configuration in Ubuntu 16.04.2 LTS
root@Ubuntu:/# cat /etc/.bash_aliases
alias i='ifconfig | grep eth -A 1'
alias l='ls -lh'
root@Ubuntu:/#
root@Ubuntu:/# cat /etc/bash.bashrc
### *output truncated* ###
if [ -f /etc/.bash_aliases ]; then
. /etc/.bash_aliases
fi
root@Ubuntu:/#
However, when I test it, only alias i='ifconfig | grep eth -A 1'
is working as expected.
root@Ubuntu:/# i
eth0 Link encap:Ethernet HWaddr AA:AA:AA:AA:AA:AA
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
root@Ubuntu:/#
root@Ubuntu:/# alias i
alias i='ifconfig | grep eth -A 1'
root@Ubuntu:/#
Another alias alias l='ls -lh'
does not work as expected.
root@Ubuntu:/# l
bin/ dev/ home/
root@Ubuntu:/#
The output should be like this:
root@Ubuntu:/# ls -lh
total 80K
drwxr-xr-x 2 root root 4.0K Jul 21 14:37 bin
drwxr-xr-x 3 root root 4.0K Jul 21 14:52 boot
drwxr-xr-x 15 root root 3.8K Nov 3 12:22 dev
root@Ubuntu:/#
It turns out that l
does not follow my alias config.
root@Ubuntu:/# alias l
alias l='ls -CF'
root@Ubuntu:/#
I guess alias l='ls -CF'
must be configured at somewhere else.
The question is how to find out the location of alias l='ls -CF'
config file?
/etc/profile
, look at all the files it sources. Then look at your own .bash_profile or .profile and look at all the files they source. Then look at your .bashrc and all the files it sources. – glenn jackman Nov 03 '17 at 14:44alias l='ls -CF'
is defined in/etc/skel/.bashrc
, which by default will get copied to all new accounts on creation (including that ofroot
) – steeldriver Nov 03 '17 at 14:49The reason why I put this on /etc/... and not my own directory because this is a test image and I've multiple test users.
I would like to use the same alias on each test users.
Is there a way to find this alias file automatically instead of manual way?
– Charlotte Russell Nov 03 '17 at 14:51/etc/skel/.bashrc
or (since it sources~/.bash_aliases
if present after the default alias definitions) provide a suitable~/.bash_aliases
that overrides it again. – steeldriver Nov 03 '17 at 15:18lh
, so it won't get overwritten by the default~/.bashrc
. This has an added benefit of not confusing users who expectl
to be aliased tols -CF
. – wjandrea Nov 04 '17 at 01:36