Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

db2 command not found in unix

Tags:

unix

db2

I am trying to execute a simple db2 command in Linux command prompt. but Linux command prompt is not recognizing the command it is giving - bash db2 command not found. but db2 is installed in the Linux machine.

command I am trying to execute from Linux command line processor is db2 "create database smaple"

Error I am getting is below "If db2 in not a typo you can run the following command to lookup the package that contains the binary" command-not-found db2 -bash: db2: command not found"

Is this because of environment variable problem ?? or there is only one instance of db2 ie db2inst1 is running in the machine.my user name in appsusr and db2 instance name is db2inst1 are different is this causing problem?? and I am not having super user access.Is this is causing any problem?? do I need super user access is required ??

like image 369
Chandan D N Avatar asked Jan 12 '15 08:01

Chandan D N


People also ask

How run Db2 command in Linux?

Start a terminal session, or type Alt + F2 to bring up the Linux "Run Command" dialog. Type db2cc to start the DB2 Control Center.

How do I know if Db2 is installed on Linux?

You can try db2level . If there is a DB2 installed, usually you can get a message like the following: $ db2level DB21085I This instance or install (instance name, where applicable: "iidev20") uses "64" bits and DB2 code release "SQL11015" with level identifier "0206010F". Informational tokens are "DB2 v11.


2 Answers

Just type, echo $PATH in your command prompt , where you can see all the exported paths in your system.

If the db2 path is not found in your environment variable list, then do the following.

export PATH=$PATH:/opt/IBM/db2/V10.1/bin

and then press enter. I hope this will resolve your issue.

like image 152
Shivaraj Bhat Avatar answered Oct 31 '22 13:10

Shivaraj Bhat


On Linux and UNIX DB2 platforms, the proper way to set your environment variables to run DB2 commands is to source the sqllib/db2profile script belonging to the local DB2 instance owner. That will set not only your PATH but also other important variables that DB2 requires.

In your case, the instance is owned by the db2inst1 user, so your login startup file or batch script should run this command:

. ~db2inst1/sqllib/db2profile

The leading dot is necessary to set the variables in your current shell process, not the sub-process that quickly vanishes after db2profile finishes.

like image 4
Fred Sobotka Avatar answered Oct 31 '22 14:10

Fred Sobotka