Db2 command not found on unix
I am trying to execute a simple db2 command on Linux command line. but Linux command line does not recognize the command it gives - bash db2 command not found. but db2 is installed on Linux machine.
the command I am trying to execute from Linux is for command line: db2 "create database smaple"
The error I am getting is below . If db2 is not a typo, you can run the following command to find the package containing the "command-not-found db2 - bash: db2: not found" binary command
Is it because of the environment variables problem ?? or there is only one instance of db2, i.e. db2inst1 works in username machine.my in appsusr and db2 instance name db2inst1 is different from this problem? and I don't have superuser access. Is this causing any problems? do i need superuser access?
source to share
Just enter echo $ PATH on the command line, where you can see all the exported paths on your system.
If the db2 path is not found in the list of environment variables, follow these steps.
export PATH = $ PATH: /opt/IBM/db2/V10.1/bin
and then press the enter key. I hope this solves your problem.
source to share
It is more than likely that if DB2 is installed, it is simply not in your path.
Your path should have something like:
/opt/IBM/db2/V10.1/bin
where the executables are located (depending on which version you are using).
Changing your path will likely entail changes in one of your startup files such as .bashrc
or .bash_profile
.
source to share
On Linux and UNIX DB2 platforms, the correct way to set environment variables for running DB2 commands is the sqllib/db2profile
script source owned by the local DB2 instance owner. This sets not only yours PATH
, but also other important variables that DB2 requires.
In your case, the instance is owned by the user db2inst1
, so your login file or batch script should execute this command:
. ~db2inst1/sqllib/db2profile
The pivot point is needed to set variables in the current shell process, not a sub-process that quickly disappears after db2profile exits.
source to share