Skip to content

nixCraft

Linux and Unix tutorials for new and seasoned sysadmin

  • Home
  • About
  • Linux Shell Scripting TutoriaL
  • RSS/Feed
  • Donations
Search

nixCraft

Linux and Unix tutorials for new and seasoned sysadmin

nixCraft

Tag: user profile

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

in Categories BASH Shell, CentOS, Debian / Ubuntu, FreeBSD, Linux, RedHat and Friends, Solaris-Unix, Suse, Ubuntu Linux, UNIX, Windows last updated August 24, 2007

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

6 Comments

Featured Articles:

  • 30 Cool Open Source Software I Discovered in 2013
  • 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
  • Top 30 Nmap Command Examples For Sys/Network Admins
  • 25 PHP Security Best Practices For Sys Admins
  • 20 Linux System Monitoring Tools Every SysAdmin Should Know
  • 20 Linux Server Hardening Security Tips
  • Linux: 20 Iptables Examples For New SysAdmins
  • Top 20 OpenSSH Server Best Security Practices
  • Top 20 Nginx WebServer Best Security Practices
  • 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
  • 15 Greatest Open Source Terminal Applications Of 2012
  • My 10 UNIX Command Line Mistakes
  • Top 10 Open Source Web-Based Project Management Software
  • Top 5 Email Client For Linux, Mac OS X, and Windows Users
  • The Novice Guide To Buying A Linux Laptop

Sign up for my newsletter

Sign up for my newsletter

Follow us

TwitterFacebookGoogle+



RSS Recently updated

  • How To Use Bash Parameter Substitution Like A Pro
  • How To Run Multiple SSH Command On Remote Machine And Exit Safely
  • Delete all root mail / inbox on Linux / Unix from a shell prompt
  • How to use lftp to accelerate ftp/https download speed on Linux/UNIX
  • How To Recover Linux Grub Boot Loader Password
  • OpenBSD install or add binary software package using pkg_add
  • How to use yum-cron to automatically update RHEL/CentOS Linux
  • Download Tux Paint Program For Young Children (Linux/macOS/Windows)
  • Linux Find Out Last System Reboot Time and Date Command
  • Linux wget: Your Ultimate Command Line Downloader
nixCraft @2000-2018 nixCraft. All rights reserved.
  • PRIVACY
  • TERM OF SERVICE
  • CONTACT/EMAIL
  • DONATIONS
Hosted by Linode
DNS & CDN by Cloudflare
Designed and Developed by Prospect One