COME OUT OF BASH CMD

I switched to oracle user from root and start to see bash commandline which looks uncomfortable to work without absolute path directory

root@orsol:~# su - oracle
Oracle Corporation      SunOS 5.11      11.4    Aug 2018
-bash-4.4$ export SHELL=/usr/bin/bash
-bash-4.4$
-bash-4.4$
-bash-4.4$ export PATH=/usr/bin:/usr/sbin
-bash-4.4$ _=/usr/bin/env
-bash-4.4$ export PATH=/usr/bin:/usr/sbin:/usr/bin/env
-bash-4.4$

I checked the environment variables of root and crossverified for oracle user

root@orsol:~# env
HZ=
PAGER=/usr/bin/less -ins
PWD=/root
HOME=/root
MAIL=/var/mail/root
SHELL=/usr/bin/bash
TERM=xterm
SHLVL=1
LOGNAME=root
PATH=/usr/bin:/usr/sbin
_=/usr/bin/env
OLDPWD=/root

Checked the present working directory

-bash-4.4$ pwd
/export/home/oracle

Checked env of oracle

-bash-4.4$ env
OLDPWD=/home/oracle
HZ=
PWD=/
HOME=/export/home/oracle
MAIL=/var/mail/oracle
SHELL=/usr/bin/bash
TERM=xterm
SHLVL=1
LOGNAME=oracle
PATH=/usr/bin:/usr/sbin:/usr/bin/env
_=/usr/bin/env
-bash-4.4$ export HOME=/home/oracle

Typing bash goes to the username@hostname format which i was looking for

-bash-4.4$ bash
oracle@orsol:/$

Copy the profile file to the home directory

root@orsol:~# cp ~/.profile /export/home/oracle/

Verify if PATH variable and shell variable are set

oracle@orsol:~$ cat ~/.profile
#
# Simple profile places /usr/bin at front, followed by /usr/sbin.
#
# Use less(1) or more(1) as the default pager for the man(1) command.
#
export PATH=/usr/bin:/usr/sbin

if [ -f /usr/bin/less ]; then
    export PAGER="/usr/bin/less -ins"
elif [ -f /usr/bin/more ]; then
    export PAGER="/usr/bin/more -s"
fi

#
# Define default prompt to <username>@<hostname>:<path><"($|#) ">
# and print '#' for user "root" and '$' for normal users.
#
# Currently this is only done for bash/pfbash(1).
#

case ${SHELL} in
*bash)
    typeset +x PS1="\u@\h:\w\\$ "
    ;;
esac

Source the profile to make permanent changes

oracle@orsol:~$ source ~/.profile
oracle@orsol:~$

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s