5 Replies Latest reply on Feb 21, 2012 10:41 PM by EdStevens

    .bash_profile location

    GabyPR
      I installed Oracle Linux 5.7. I need to view the .bash_profile file or whatever file Oracle Linux uses to store the environment variables for a user. I am working with the "oracle" user whose home directory is /home/oracle.
      Connected as "oracle" I issued the "env" command and many variables are shown to have been set already.
      I issue the export command to set the PATH variable and the changes are shown when I issue the "env" command.

      So everything seems to be working but I don't find where all those settings are stored. I went to the /home/oracle directory and I only saw a .bash_history file. So I created a new file named .bash_profile, but the variables are not stored there when I issue the export command. (the file I created was before I noticed that variables are already being set somewhere else - on a file I did not find).

      So where are they ??? The only thing I need to know is how to locate the file the system is using right now to store the environment variables, I supposed it has to be located under the $home directory for the user but it seems it is not that way. Anybody knows something about this ??

      The /etc/profile file I understand is a general file for global settings, so it's not what I'm looking for as far as I know.

      here's the output of the env command issued connected as "oracle" ... I need to know on what file they are stored.

      bash-3.2$ env

      SSH_AGENT_PID=8782
      HOSTNAME=Oracle.Linux
      DESKTOP_STARTUP_ID=
      TERM=xterm
      SHELL=/bin/bash
      HISTSIZE=1000
      KDE_NO_IPV6=1
      GTK_RC_FILES=/etc/gtk/gtkrc:/home/oracle/.gtkrc-1.2-gnome2
      WINDOWID=25165905
      QTDIR=/usr/lib/qt-3.3
      QTINC=/usr/lib/qt-3.3/include
      USER=oracle
      LS_COLORS=
      GNOME_KEYRING_SOCKET=/tmp/keyring-EbBsIZ/socket
      SSH_AUTH_SOCK=/tmp/ssh-OcrBnl8746/agent.8746
      KDEDIR=/usr
      SESSION_MANAGER=local/Oracle.Linux:/tmp/.ICE-unix/8746
      USERNAME=oracle
      MAIL=/var/spool/mail/oracle
      PATH=/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin
      DESKTOP_SESSION=default
      GDM_XSERVER_LOCATION=local
      INPUTRC=/etc/inputrc
      PWD=/home/oracle
      XMODIFIERS=@im=none
      KDE_IS_PRELINKED=1
      LANG=en_US.UTF-8
      GDMSESSION=default
      SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
      SHLVL=2
      HOME=/home/oracle
      GNOME_DESKTOP_SESSION_ID=Default
      LOGNAME=oracle
      QTLIB=/usr/lib/qt-3.3/lib
      CVS_RSH=ssh
      DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-dgt3DUIWif,guid=bb5dcea335860598b6a290004f42d4f7
      LESSOPEN=|/usr/bin/lesspipe.sh %s
      DISPLAY=:0.0
      G_BROKEN_FILENAMES=1
      COLORTERM=gnome-terminal
      XAUTHORITY=/tmp/.gdmR05GAW
      _=/usr/bin/env
      bash-3.2$
        • 1. Re: .bash_profile location
          Dude!
          Most likely there is nothing wrong with the OS, but how the user was created. A user under Linux is normally created using "useradd" program, which will copy files from the /etc/skel directory like .bash_logout, .bash_profile and .bashrc. You need "ls -a" to list hidden files starting with a . (dot).

          According to the bash man page, Bash first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist.
          1 person found this helpful
          • 2. Re: .bash_profile location
            EdStevens
            GabyPR wrote:
            I installed Oracle Linux 5.7. I need to view the .bash_profile file or whatever file Oracle Linux uses to store the environment variables for a user. I am working with the "oracle" user whose home directory is /home/oracle.
            Connected as "oracle" I issued the "env" command and many variables are shown to have been set already.
            I issue the export command to set the PATH variable and the changes are shown when I issue the "env" command.

            So everything seems to be working but I don't find where all those settings are stored. I went to the /home/oracle directory and I only saw a .bash_history file. So I created a new file named .bash_profile, but the variables are not stored there when I issue the export command. (the file I created was before I noticed that variables are already being set somewhere else - on a file I did not find).
            They aren't 'stored' anywhere. Well, they are stored in memory, for the session in which the 'export' command was executed. The .profile (or .bash_profile) is executed by the OS when the owning user first logs on. It is not (as your question seems to imply) updated when you execute an 'export' command. You need open the .profile and put those export commands into the file, so that they get executed when you log on.
            So where are they ??? The only thing I need to know is how to locate the file the system is using right now to store the environment variables, I supposed it has to be located under the $home directory for the user but it seems it is not that way. Anybody knows something about this ??

            The /etc/profile file I understand is a general file for global settings, so it's not what I'm looking for as far as I know.

            here's the output of the env command issued connected as "oracle" ... I need to know on what file they are stored.

            bash-3.2$ env

            SSH_AGENT_PID=8782
            HOSTNAME=Oracle.Linux
            DESKTOP_STARTUP_ID=
            TERM=xterm
            SHELL=/bin/bash
            HISTSIZE=1000
            KDE_NO_IPV6=1
            GTK_RC_FILES=/etc/gtk/gtkrc:/home/oracle/.gtkrc-1.2-gnome2
            WINDOWID=25165905
            QTDIR=/usr/lib/qt-3.3
            QTINC=/usr/lib/qt-3.3/include
            USER=oracle
            LS_COLORS=
            GNOME_KEYRING_SOCKET=/tmp/keyring-EbBsIZ/socket
            SSH_AUTH_SOCK=/tmp/ssh-OcrBnl8746/agent.8746
            KDEDIR=/usr
            SESSION_MANAGER=local/Oracle.Linux:/tmp/.ICE-unix/8746
            USERNAME=oracle
            MAIL=/var/spool/mail/oracle
            PATH=/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin
            DESKTOP_SESSION=default
            GDM_XSERVER_LOCATION=local
            INPUTRC=/etc/inputrc
            PWD=/home/oracle
            XMODIFIERS=@im=none
            KDE_IS_PRELINKED=1
            LANG=en_US.UTF-8
            GDMSESSION=default
            SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
            SHLVL=2
            HOME=/home/oracle
            GNOME_DESKTOP_SESSION_ID=Default
            LOGNAME=oracle
            QTLIB=/usr/lib/qt-3.3/lib
            CVS_RSH=ssh
            DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-dgt3DUIWif,guid=bb5dcea335860598b6a290004f42d4f7
            LESSOPEN=|/usr/bin/lesspipe.sh %s
            DISPLAY=:0.0
            G_BROKEN_FILENAMES=1
            COLORTERM=gnome-terminal
            XAUTHORITY=/tmp/.gdmR05GAW
            _=/usr/bin/env
            bash-3.2$
            • 3. Re: .bash_profile location
              GabyPR
              You clarified me about my thinking of that I thought the profile file is like a configuration file, like a "pfile" in Oracle.
              But I see it's not that way. Anyway I wonder why I had to create a blank file name .bash_profile under the home directory, I thought Linux would create a "default" one there with that name. Anyway I will enter some instructions and export commands there to see if they are implemented, ie, to see if Linux is reading it at login.

              Thanks so much for your help
              Gabriel
              • 4. Re: .bash_profile location
                Dude!
                Sorry, but your conclusion is wrong. The login-profile files serve a very similar purpose to the command shell like the "pfile" to the Oracle Instance, albeit using a different command syntax.

                The reason why you do not have a .bash_profile file, like I tried to explain earlier, is most likely because you probably did not use the "useradd" command to create the oracle user or deleted the file by accident. You can copy the files from /etc/skel, e.g. cp /etc/skel/.bash_profile $HOME

                The Oracle installer will setup variables necessary for the Oracle DBA like ORACLE_HOME, etc. These variables are not stored in any of the login profile files, but they can be generated by source executing the Oracle "oraenv" utility. It's covered in the Oracle database installation manual.
                1 person found this helpful
                • 5. Re: .bash_profile location
                  EdStevens
                  GabyPR wrote:
                  You clarified me about my thinking of that I thought the profile file is like a configuration file, like a "pfile" in Oracle.
                  But I see it's not that way. Anyway I wonder why I had to create a blank file name .bash_profile under the home directory, I thought Linux would create a "default" one there with that name. Anyway I will enter some instructions and export commands there to see if they are implemented, ie, to see if Linux is reading it at login.

                  Thanks so much for your help
                  Gabriel
                  You're not in Kansas (Windows) any more. Unlike Windows, nix does not try to be smarter than the user, does not try to (wrongly) anticipate what the user wants.  On the other hand, you'll not have to restart every day.  Unlike Windows, in nix the first three troublshooting steps are NOT "ctrl", "alt", and "del".
                  1 person found this helpful