how to find if 2 databases are installed on the system?
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You question is not specific enough. What kind of databases? What kind of web servers? There are my flavors and variants of each. What are you actually asking? Give the "forest" of the problem and not the "trees".
You question is not specific enough. What kind of databases? What kind of web servers? There are my flavors and variants of each. What are you actually asking? Give the "forest" of the problem and not the "trees".
okay ... suppose that i have MySQL and oracle/IBM DB2 etc installed... Now i just want to find out how many such databases are installed...
eg : - if only MySQL --> output 1... if MySQL + oracle --? output 2
similarly if i just have apache output 1... if i have apache and say nginx then output 2...
Database servers and web servers are no different from other applications installed on your system; they are simply a bunch of files (executables, libraries, configuration files, data files) that reside in various directories.
To figure out if application "X" in installed on a system, you can:
search for files with names associated with the application in question (which may return a false positive if an unrelated file with a similar name exists somewhere)
try and execute an application-related file with a parameter known to return a certain value, like "mysql --version", and check the result (which may fail in interesting ways if an unrelated script or executable by that name exists, or if the parameter has been deprecated in a later version of the application)
search through the list of installed applications provided by the package manager of your distribution, which would be rpm on CentOS (which is safe, but will miss any applications installed directly from source code)
Bottom line, you'll have to know exactly what you're looking for, and select a method appropriate for the systems you'll be examining. For CentOS, rpm -a | grep <some_filter> or rpm -q <package> may be what you're looking for.
okay ... suppose that i have MySQL and oracle/IBM DB2 etc installed... Now i just want to find out how many such databases are installed...
eg : - if only MySQL --> output 1... if MySQL + oracle --? output 2
similarly if i just have apache output 1... if i have apache and say nginx then output 2...
That's what i want to find out...
Your question is still ambiguous. Both MySQL and Oracle are capable of having multiple databases within the same instances. If you're attempting software detection then this will depend on the target OS you're querying. Sometimes it can be found via package management or you can simply query their utilities.
My question to you is... what is your actual question? What is your end goal? Are you attempting to inventory? Are you attempting to audit? Need more info.
isn't there any way by which without know the names of these applications i could get this result...
maybe there's some file which might be holding that data like how many database servers are there and their names ...
Nope.
You need to specifically look for the application(s). You also cannot rely on the package manager (rpm/yum for RHEL based systems) information: What if the package manager wasn't used (application was build and installed from source)....
Ser Olmy's reply put you on the correct path to tackle this problem.
My main aim is to detect number of database servers installed on the system... then i intend to scan the config files of these servers to check if they are securely configured...
My main aim is to detect number of database servers installed on the system... then i intend to scan the config files of these servers to check if they are securely configured...
That's an ambitious goal......
There are many DB servers out there, most common are Oracle, MySQL, PostgreSQL, DB2, Sybase and Ingres (I might have overlook one or two as I'm not a DB admin).
The same is true for web servers. Common are: Apache, Nginx, Lighttpd and Sun ONE Web Server (don't know if oracle renamed it).
But you probably need to look at application servers too. Common are: Tomcat, JBoss, WebSphere and BEA Weblogic.
Depending on the platform/distro used the essential files may be in different locations.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.