Operating System - HP-UX
1833861 Members
1966 Online
110063 Solutions
New Discussion

Chapter III - User's environments and /etc/profile

 
SOLVED
Go to solution
rustam_2
Super Advisor

Re: Chapter III - User's environments and /etc/profile

Hi Horia and Dennis,
>> The only situation when bash does not interpret the profile file, is when the binary itself is called with --noprofile option.
how can i change noprofile option?

>>You must know where your shell binary exists (if it is /bin/bash or /usr/bin/bash).
bash exist in both directory.

>>I believe /bin/bash is your binary used as the shell.
How can i check current shell?

>> Does ~/.bash_profile exist?
Yeah, ~/.bash_profile exist and i typed content of this file above.

>> only put your bash specific stuff in ~/.bash_profile.
it was\is first way to solve problem, how?

Dennis Handly
Acclaimed Contributor

Re: Chapter III - User's environments and /etc/profile

>how can I change noprofile option?

It isn't likely that option is used at all.

>bash exist in both directory.

More accurately they ARE the same directory.

>How can I check current shell?

ps -fp $$
Or type an invalid command as see if the shell name is in the error message.

>> only put your bash specific stuff in ~/.bash_profile.
>it was/is first way to solve problem, how?

If you always use ~/.profile, it can work for ksh/sh/base. Then if you need some fancy extra stuff for bash, add it to ~/.bash_profile.
rustam_2
Super Advisor

Re: Chapter III - User's environments and /etc/profile

Hi Dennis,
the command # ps -fp $$
returned me ... COMMAND
... bash
i determined through the $swlist that bash was installed.

I just want to activate bash and use .bash_profile for my user. Are there specific command to activate bash interpreter? In the passwd file i have this argument.
...:/home/oraprd:/bin/bash

Patrick Wallek
Honored Contributor

Re: Chapter III - User's environments and /etc/profile

>>In the passwd file i have this argument.
...:/home/oraprd:/bin/bash

Then that user will use the bash shell when they log in, if bash is really in the /bin directory.

NOTE: In HP-UX /bin is a link to /usr/bin. /bin/bash will work, if the link is present, but /usr/bin/bash is preferred.
rustam_2
Super Advisor

Re: Chapter III - User's environments and /etc/profile

Patrick,
bash exist in /bin, /usr/bin/
when i'm typing wrong command, i get error:
# iffconfig
bash: iffconfig: command not found

so it means my shell is BASH right now. But it doesnt work ~/.profile when i switch
between users.

Regards,
Rustam
Horia Chirculescu
Honored Contributor

Re: Chapter III - User's environments and /etc/profile

Hello, Rustam

>How can I check current shell?

When you are using bash, it defines a variable named "BASH".

Sample:

This user have posix shell as login shell

# set |grep bash
_=bash

He likes to use bash. afther enetering bash shell, the variable is defined:

# bash
# set |grep bash
BASH=/usr/local/bin/bash
_=/usr/local/bin/bash
#


>But it doesnt work ~/.profile when i switch
between users.

What do you mean by "i switch between users."?

~/.profile it is sourced by shell only when the shell it is invoked as a login shell.

If you invoke the shell as a subshell, .profile is not interpreted.

All put together, if you "switch" between users like this:

su new_user

The .profile would not be sourced.

If you call su like this

su - new_user

you would get the expected behavior.

Please read the documentation - man pages.
It is a must for every administrator (novice or expert).

Horia.
Best regards from Romania,
Horia.
Horia Chirculescu
Honored Contributor

Re: Chapter III - User's environments and /etc/profile

You can source ~/.profile just after invoking bash shell (as a subshell) by calling:

#bash
#source ~/.profile

This would set the variables defined in that .profile file.

Horia.
Best regards from Romania,
Horia.
Dennis Handly
Acclaimed Contributor

Re: Chapter III - User's environments and /etc/profile

>Patrick: but /usr/bin/bash is preferred.

If you are using NIS to share between HP-UX and Linux, it'll work better with /bin/.
Patrick Wallek
Honored Contributor

Re: Chapter III - User's environments and /etc/profile

>>If you are using NIS to share between HP-UX and Linux, it'll work better with /bin/.

True, but aren't the /bin and /lib transition links supposed to go away at some point?
Dennis Handly
Acclaimed Contributor

Re: Chapter III - User's environments and /etc/profile

>Patrick: but aren't the /bin and /lib transition links supposed to go away at some point?

No, after more than a decade Tlinks were changed to be permanent on 11.31.
rustam_2
Super Advisor

Re: Chapter III - User's environments and /etc/profile

Hi all,
i've done these steps today:
1. changed passwd file more exactly value for my oracle user
from
oralce:*:*:*:*:/home/oracle:/bin/bash
to
oralce:*:*:*:*:/home/oracle:/usr/local/bin/bash

so i have bash SHELL right now.
And now i found out that script which i mentioned above is wrong(i guess). Now i have to think about how to change my script.


Horia Chirculescu
Honored Contributor

Re: Chapter III - User's environments and /etc/profile

>from
>oralce:*:*:*:*:/home/oracle:/bin/bash
>to
>oralce:*:*:*:*:/home/oracle:/usr/local/bin/bash

Maybe /bin/bash and /usr/local/bin/bash are the same binary.

In order to find out:

ll /bin/bash /usr/local/bin/bash

What does it tell you , /bin/bash is a symlink?

>so i have bash SHELL right now.


I believe oralce user had bash login shell even before you did the changes in /etc/passwd



>And now i found out that script which i mentioned above is wrong(i guess). Now i have to think about how to change my script.


What script are you talking about?

Horia.
Best regards from Romania,
Horia.
rustam_2
Super Advisor

Re: Chapter III - User's environments and /etc/profile

maybe Horia,
----
in my first post i brought part code from my script.
In upload photo i gave whole code. These code must be load when i login with oracle user. But doesn't work. Maybe there some mistakes.

p.s. i deleted some values such as display's, oracle_sid's, oracle_home's.
Horia Chirculescu
Honored Contributor

Re: Chapter III - User's environments and /etc/profile

>In upload photo i gave whole code. These code must be load when i login with oracle user. But doesn't work. Maybe there some mistakes.

This would be the .bash_profile file, right?
And you have put it in this directory:

/home/oracle

I mean, as root:

cat /home/oracle/.bash_profile

would list the content from your last attached picture, right?

Can you be more specific? What exactly does not work? What is the content of ~/.aliases ?

DISPLAY variable (if defined) should also be exported.

I believe you understand what I was talking about in my previous post:

"
What do you mean by "i switch between users."?

~/.profile it is sourced by shell only when the shell it is invoked as a login shell.

If you invoke the shell as a subshell, .profile is not interpreted.

All put together, if you "switch" between users like this:

su new_user

The .profile would not be sourced.

If you call su like this

su - new_user

you would get the expected behavior.

Please read the documentation - man pages.
It is a must for every administrator (novice or expert).
"

Just play yourself with those settings in order to get a better picture.

Horia.
Best regards from Romania,
Horia.
Dennis Handly
Acclaimed Contributor

Re: Chapter III - User's environments and /etc/profile

>In upload photo I gave whole code.

FYI: While a picture may be worth a thousand words, an attached text file is golden and can be manipulated and quoted.

As Horia asked, what doesn't work?
You can also add "set -x" (at least in a real shell) to trace execution.
rustam_2
Super Advisor

Re: Chapter III - User's environments and /etc/profile

Problem was here
>>All put together, if you "switch" between users like this:

su new_user

The .profile would not be sourced.

If you call su like this

su - new_user

i called su - oracle and file ~./bash_profile worked correctly and got everything which are in file.

Thanks a lot Horia and Dennis.