≡ Menu

Ubuntu Set User Profile Under Bash Shell

How do I set user profile under bash shell running Ubuntu Linux operating systems?

You need to edit the following files to set profile for users.

Systemwide Profile For All Users

/etc/profile: You need to update /etc/profile which is systemwide initialization profile file. All changes made to this file applies to all users on the system.

/etc/bash.bashrc : The systemwide per-interactive-shell startup file. This file is called from /etc/profile. Edit this file and set settings such as JAVA PATH, CLASSPATH and so on.

How Do I Edit Systemwide Profile Files?

Use the text editor such as vi:
sudo vi /etc/profile

Profile For Individual Users

Use the following shell startup files to customize each user profile. The following files are located in users $HOME directory such as /home/vivek.

  1. $HOME/.bash_profile – The personal initialization file, executed for login shells. Add PATH settings and other user specific variables to this file.
  2. $HOME/.bashrc – The individual per-interactive-shell startup file. Add user specific aliases and functions to this file.
  3. $HOME/.bash_logout – The individual login shell cleanup file, executed when a login shell exits.

You can edit above files with the following command:
vi ~/.bashrc
vi $HOME/.bash_profile

Sample $HOME/.bash_profile

# shell path
export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
export EDITOR=vim
export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre

# load ssg keys
/usr/bin/keychain $HOME/.ssh/id_dsa
source $HOME/.keychain/$HOSTNAME-sh

# turn on directory spelling typos
shopt -s cdspell

Sample $HOME/.bashrc

# shell functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias vi='vim'
alias grep='grep --color'
alias update='sudo apt-get update && sudo apt-get upgrade'
alias dnstop='dnstop -l 5  eth1'
alias vnstat='vnstat -i eth1'
alias bc='bc -l'

genpasswd() {
	local l=$1
       	[ "$l" == "" ] && l=16
      	tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs

	local o=$IFS
	IFS=$(echo -en "\n\b")
	/usr/bin/beep-media-player "$(cat  $@)" &

Recommended readings:

Share this tutorial on:

Like this? Follow us on Twitter OR support us by using Patreon

{ 4 comments… add one }
  • David Bowskill July 15, 2012, 7:17 am

    Very helpful info – would like to receive more – Thanks

  • Carlos July 12, 2014, 1:11 pm


    I have a doubt:

    Why does the article recommends to set the user specific path and variables in .bash_profile file, and not in .bash_rc?. Why does the article recommend to set the functions and aliases in .bash_rc and not in .bash_profile file?


  • Gustavo Piva November 9, 2014, 2:01 pm

    Thank you for this notes. I’m finding for this information a few days.

  • satish January 5, 2017, 5:39 am

    what is the use of /etc/. and /profile/ configuration file?

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , , , , , , , , ,