Inspect system aliases in /etc/bash.bashrc
In addition to user-specific configuration files like ~/.bashrc
, there are also system-wide configuration files that apply to all users on the system. For Bash, one such file is /etc/bash.bashrc
.
This file often contains default settings and aliases that the system administrator wants to be available to everyone.
Since this file is located in the /etc
directory, which is typically reserved for system configuration, you might need administrator privileges to modify it. However, we can view its contents using cat
without special permissions.
Let's view the contents of the /etc/bash.bashrc
file. Type the following command and press Enter:
cat /etc/bash.bashrc
You will see the content of the system-wide Bash configuration file. Look for lines that define aliases.
## System-wide .bashrc file for interactive bash(1) shells.
## To enable the setting of the locale environment variables see
## /etc/profile.d/locale.sh. By default in Ubuntu OnLine,
## this is done from /etc/profile.
## If not running interactively, don't do anything
[ -z "$PS1" ] && return
## check the window size after each command and, if necessary,
## update the values of LINES and COLUMNS.
shopt -s checkwinsize
## If set, the pattern "**" used in a pathname expansion context should
## match only directories and subdirectories in addition to the contents of
## the current directory.
#shopt -s globstar
## make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
## set variable identifying the chroot you work in (used in the prompt)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
## enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
## colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=(01;34):quote=01;32'
## some more ls aliases
#alias ll='ls -l' #alias ll='ls -alF'
#alias la='ls -a' #alias la='ls -AF'
#alias l='ls -CF'
## Add an alias for the 'alert' command
#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$//'\'')"'
## enable programmable completion features (you don't need to enable
## this, if it's already enabled in /etc/bash.bashrc and /etc/profile
## sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
You should see some of the same aliases you saw with the alias
command, such as the ls
alias with color support. This confirms that some of the default aliases you use are set system-wide.
Understanding where aliases are defined helps you troubleshoot unexpected behavior and customize your environment effectively.
You have now learned how to list active aliases and inspect common configuration files where they are stored.
Click Continue to complete this lab.