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
fi
if [ -d ~/bin ] ; then
PATH=~/bin:"${PATH}"
fi
alias dironly='printf "%s\n" */'
alias dironlyv='echo */.'
alias dragon=~/bin/showMenu.pl
export PATH=/usr/lib/jvm/java-6-sun-1.6.0.00/bin:${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
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- How do I backup Thunderbird mail and profile under Linux?
- Environment variable changing on Linux/FreeBSD
- Qmail delivering mail ~/Mailbox home directories
- How to Set JAVA_HOME / PATH variables Under Linux Bash Profile
- Setting bash as default shell
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: bashrc_file, bash_profile_file, bash_shell, change_profile, etc_profile_file, export_path, global_profile, initialization, interactive_shell, jvm_java, login_shells, set_environment_variables, shell_commands, umask, user_profile



Recent Comments
Today ~ 3 Comments
Today ~ 57 Comments
Yesterday ~ 9 Comments
Yesterday ~ 7 Comments
Yesterday ~ 1 Comment