How to: Change User’s bash profile under Linux / UNIX

Q. How do I change my own profile? How do I change profile for other users? How do I setup global profile for all users under BASH shell?

A.. You need to add user profile to ~/.bash_profile. It is the personal initialization file, executed for login shells. There is also ~/.bashrc file which is the individual per-interactive-shell startup file. Common uses for ~/.bash_profile are to set environment variables such as PATH, JAVA_HOME, create aliases for shell commands and set the default permissions for newly created files etc. The file ~/.bashrc is similar, with the exception that .bash_profile runs only for Bash login shells and .bashrc runs for every new Bash shell.

Edit user .bash_profile file

Use vi command:
$ cd
$ vi .bash_profile

My same profile:

umask 022
if [ -f ~/.bashrc ]; then
    . ~/.bashrc

if [ -d ~/bin ] ; then

alias dironly='printf "%s\n" */'
alias dironlyv='echo */.'
alias dragon=~/bin/ 
export PATH=/usr/lib/jvm/java-6-sun-${PATH}

.bashrc vs .bash_profile files

Let us see the difference with these two scripts:

~/.bashrc file runs every time you open a new non-login bash shell such as xterm / aterm, and ~/.bash_profile runs only with login shells i.e when you first log in into system.

/etc/profile – System wide global profile

The /etc/profile file is systemwide initialization file, executed for login shells. You can edit file using vi (login as root):
# vi /etc/profile

🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
6 comments… add one
  • vasudha Aug 11, 2011 @ 5:09


    In order to get profile u need to have ~/.bashrc
    It contains setting
    ==> for your shell promt display
    ==> colour settings based on the permission (example exe fles appear green

    So I suggest you copy the bashrc and bash_profile and bash from any linux server into your login and run the following command to change our profile

  • shyam Oct 30, 2011 @ 15:54

    what is user profile and .profile in unix…waiting for your replay

  • Somnath Jan 18, 2012 @ 11:44

    My problem: Today I started to install sysstat monitor tool for my OS X by using 1. apt-get install sysstat 2. yum install sys stat 3. rpm -i sys stat.rpm none of then worked.

    Even I cannot execute some unix commands from my

    Then I tried to see echo $PATH but the output is empty but I can start my TOMCAT and close.

    NoW I cannot locate .profile or .bash_profile using the ls -a command. But still TOMCAt is working.. So It seems I messed up :) Please let me know the reason? It is really deleted but how tomcat is working (as in OS x the java no need to be specified in .profile)?.

    So Please help me to understand the problem and how to reconfigure it so that it can execute all commands.

  • landon kelsey Jun 17, 2012 @ 3:37

    maybe Fedora 17 is different

    put aliases in .bashrc and it works

    aliases not set when put into .bash_profile

    [landon@Precision-380 ~]$ cat .bashrc
    # .bashrc

    # Source global definitions
    if [ -f /etc/bashrc ]; then
    . /etc/bashrc
    alias lsa=’ls -alF –color’
    alias h=history

    # User specific aliases and functions
    [landon@Precision-380 ~]$

  • shyam D sudake Aug 30, 2016 @ 15:14

    by which commands i find out ORACLE_HOME,ORACLE_BASE,ORACLE_PATH,ORACLE_SID to create .bash_profile in

    • 🐧 Vivek Gite Aug 30, 2016 @ 21:34
      echo $ORACLE_HOME
      cat ~/.profile
      cat ~/.bash_profile

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @