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 "nb")
	/usr/bin/beep-media-player "$(cat  $@)" &

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Leave a Reply

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

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts