The shell stores two basic types of data in the environment, environment variables and shell variables.
To see env var
$ printenv | less
OR
$ printenv USER
himanshu
OR
$ echo $USER
himanshu
One element of the environment that neither set nor printenv displays is aliases.
$ 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'
/etc/profile
: A global configuration script that applies to all users.~/.bash_profile
: A user's personal startup file. Can be used to extend or override settings in the global configuration script.~/.bash_login
: If~/.bash_profile
is not found, bash attempts to read this script.~/.profile
: If neither~/.bash_profile
nor~/.bash_login
is found, bash attempts to read this file. This is the default in Debian-based distributions, such as Ubuntu.
/etc/bash.bashrc
: A global configuration script that applies to all users.~/.bashrc
: A user's personal startup file. Can be used to extend or override settings in the global configuration script.
$ export ME="hp"
$ echo $ME
hp
$ gedit some_file
As a general rule, to add directories to your PATH
, or define additional environment variables, place those changes in .bash_profile
. cp
will overwrite existing files silently.