PDA

View Full Version : .bash_profile interference



scottjsn
02-Oct-2012, 20:04
OS: SUSE Linux Server 11.

created a file named .bash_profile under the /home/oracle

First, without any line in the file, go to the terminal issue: su - oracle --> successfully switch to the oracle user environment
Now add, ORACLE_BASE=/u01/app/oracle export ORACLE_BASE go back to the terminal: su - oracle --> error: -bash: export : command not found

Worse, if I put these lines in the file: DISPLAY=0.0 export DISPLAY I can not even log in to the oracle user account.

Similarly, if I put DISPLAY=0.0 export DISPLAY +xhost in the /root I will not be able to log in as root.

What could be the cause?

Thanks

ab
03-Oct-2012, 03:48
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> created a file named .bash_profile under the /home/oracle

I assume, per a command like `getent passwd oracle` that /home/oracle is
indeed the user's home directory. The rest of your steps imply as much,
but this is odd so we'd might as well be thorough. I also assume that
/bin/bash is your login shell. Again, your errors seem to confirm that,
but who knows.

> First, without any line in the file, go to the terminal issue: su -
> oracle --> successfully switch to the oracle user environment

Good.

> Now add, ORACLE_BASE=/u01/app/oracle export ORACLE_BASE go back to
> the terminal: su - oracle --> error: -bash: export : command not
> found

I assume the commands above are on two lines, but I don't see that here.
Wrapping these types of things in code tags (see the 'help' for the
forums for more info) can help with this visibility. Anyway, 'export'
is a bash builtin so it's not possible for it to be missing as far as I
know. If bash is running things then bash has this builtin, at least
for all versions of bash since many years ago.

> Worse, if I put these lines in the file: DISPLAY=0.0 export DISPLAY I
> can not even log in to the oracle user account.

Unless I'm mistaken you have a typo when setting DISPLAY. Every time
I've done it, or seen it done, the syntax has had a colon that I do not
see in your case:

Code:
- --------------------
DISPLAY=:0.0
export DISPLAY
- --------------------

Also, you're welcome to combine these for all current versions of bash,
not that it will necessarily help considering your errors:

Code:
- --------------------
export DISPLAY=:0.0
- --------------------

> Similarly, if I put DISPLAY=0.0 export DISPLAY +xhost in the /root I
> will not be able to log in as root.

Same issue as above, plus for 'xhost' you should be doing something like
this:

Code:
- --------------------
xhost +
- --------------------

While we're testing, have you tried putting these commands in the
~/.bashrc file instead of the ~/.bash_profile file? I've never used (or
seen used) the latter, but I've spent most of my life in areas that used
~/.bashrc which also works nicely. Unlike the profile scripts is an
'rc' script and while I'm not an expert on the difference I use this
'rc' script for everything in my environment the same way I think you're
using your profile script. See the 'bash' manpage for tons of
information on both types of things.

Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQa6c/AAoJEF+XTK08PnB5qo0QAKt5cz/UWKdGrrZJa51QwLvk
NFSRte3wTSBI+wXEtTMo90UzeRy0wKaiqBcJ7VMdUK0iSyM+YO n3cuMiCD3hyv6x
b0tD+6mxBIIXCvVDz97EPGHgXhj4PaDMUZFm4PSMyNH/fb3qucxm6LOkWx/FVS+Y
SNbAWFrlqeaoSNbA0Bc9FXjcMeVxoQ+lMO19tdSjr4UvwT5GBb wBFhaI9+Ane8Dx
xTIo8A25ahqnb984d3yH1rZPZ6Pmvu/e+AqTd8PRcnfe0UdmPC5r4aNfirjJVGbr
vauRUUgTsyHvpXWgc8MzYUdiVlsxNBTqOXXLvvuQla5L6f+8JE gki3Me9deJ/blO
6vEhGfahYEJDg3+s8C7nk/8NV2GloDDPpYJ3h+K7tPgWlDml86E4LSrOeQuoj1fK
1j2M0UK6x/UIfA1SkI9/5bTMiq1Rss+Xtuq48D7W72r9sOSgaRqwv+VfeLiYHTCg
S4x348emna3BNkPHxTFqPISqdNKf/zy6iEytI7gzlD4CIFQBNmmZqdlLRLLp8yB0
FjDwaGzlRBdFWd7maaJ7dMsZmIrmyrFIgO3Tls5ONnlwFO3+RH ygG4N8U9fOPlO1
txHSrdWNF0kIvgqGXRZGQ5XakWPJpWVEyMsj6KMC0oFDCPvJYO Zr9ovNRfdEQm5J
AelAe2SsVQMN2TluOV4h
=oQfG
-----END PGP SIGNATURE-----

ab
03-Oct-2012, 03:56
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

As a note, I created a new user and put some of the same commands you
did in the ~/.bash_profile file, chose to use the 'bash' shell (was a
default), and could not create a failed login or errors about missing
'export' command. If I were to guess... well, I'd guess your system has
been tweaked in unexpected ways before you started doing this. Trying
on a fresh SLES system may be worthwhile, as may verifying that
/bin/bash is the same /bin/bash on systems that work (if you have some),
or that security policies and environment variables are otherwise the
same between working/broken systems.

Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQa6lLAAoJEF+XTK08PnB5slkP/AjmWp/6LWpwsyGB/5bDW8xO
RbrcZefdWEgq0xuOUZG6LY6GjXf2Zy7dpaS6+Ytc9cuPIRY00V pv8/oyeojX293A
vd1jJKc1p3HKsbBbxZGpfkBaOZ4OMJO/NY59II6CjpObY+K7GfinPwykg7uwup6t
TFc8Aq5vp9rLSebEW/3QQZWh61I2mK4B2r68igG/P50Qct0IenzeLzQzxlwbXXPk
pVeme85WEGdatUR7DuHdbsBWNzkM/w5CzzMiv52VIGPqlGkzUr23dSjsH+CggIlW
J5f5Fn3LLXHsWmCqrgon87b/n2RK5z/y6Nis6OuADp4ifT/IYS/bo6UsabCrAWf/
48p8XljJX9wHUKe3+stFEXyDR5QGW9Q2m9KisC4KvZX0nwRe7l Hsfqw/AJxtYBo5
AhClh2FPB0K+Eku7BOiV8VH2f/XQcd6Y2mH0EKN1A62DKYUx8VA9MlFJ0rRWC0/T
riwabutgxcQMlcHwr+a/tXI8OfSheqQFpBwfjqsF2K66xoI93/0RYniy0KDGpbCX
mIHy5ZQASkrpEq6WF5t+K2oylPFBEiK1rkwufM3zzTBAJDuwAd lIzlfg7Y4qh9J3
CDvOjWYV/CmyDIwDbiautDSzRTuyd+Q/2kXKE1hjj26qHh94AnW9TKWbbcZuKymT
C8XFBrannOJ8AeC7Z8Yv
=MaQN
-----END PGP SIGNATURE-----