Linux find configuration files

How to find out the location of currently used MySQL configuration file in linux

How do I know which configuration file is used by MySQL currently? Is there any command or something to find it out?

7 Answers 7

The information you want can be found by running

I tried this command on my machine:

mysql --help | grep "Default options" -A 1 
Default options are read from the following files in the given order: /etc/my.cnf /usr/local/etc/my.cnf ~/.my.cnf 

See if that works for you.

+1 Another way is ‘my_print_defaults mysqld’ (to find what options will be passed to mysqld when it’s started).

The Default options may work on a standard system. I was working on a highly configured system and the default location wasn’t available. So I used the answer below to use «locate my.cnf» which provided me the exact location of my file.

mysqld —help —verbose will find only location of default configuration file. What if you use 2 MySQL instances on the same server? It’s not going to help.

Good article about figuring it out:

New link here of the original article. When I have time I will update this answer with a summary: psce.com/blog/2012/04/01/how-to-find-mysql-configuration-file

If you are using terminal just type the following:

You can use the report process status ps command:

You should find them by default in a folder like /etc/my.cnf , maybe also depends on versions. From MySQL Configuration File:

Interestingly, the scope of this file can be set according to its location. The settings will be considered global to all MySQL servers if stored in /etc/my.cnf. It will be global to a specific server if located in the directory where the MySQL databases are stored (/usr/local/mysql/data for a binary installation, or /usr/local/var for a source installation). Finally, its scope could be limited to a specific user if located in the home directory of the MySQL user (~/.my.cnf). Keep in mind that even if MySQL does locate a my.cnf file in /etc/my.cnf (global to all MySQL servers on that machine), it will continue its search for a server-specific file, and then a user-specific file. You can think of the final configuration settings as being the result of the /etc/my.cnf, mysql-data-dir/my.cnf, and ~/.my.cnf files.

There are a few switches to package managers to list specific files.

Читайте также:  Каким процессом занята папка linux

There are switches to rpm command, -q for query, and -c or —configfiles to list config files. There is also -l or —list

The —configfiles one didn’t quiet work for me, but —list did list a few .cnf files held by mysql-server

DEB Systems:

Also with limited success: dpkg —listfiles mysql-server

Источник

How to Find MySQL, PHP and Apache Configuration Files

In this post, we will learn a number of commands for locating the default configuration files for MySQL database server (my.conf) , PHP programming language (php.ini) and Apache HTTP server (http.conf) , which together with Linux form the LAMP (Linux Apache Mysql/MariaDB PHP) stack.

A configuration file (or config file) contains system related or application settings. It gives developers and administrators control over operation of the system or an application.

As a Linux Sysadmin, knowing the location of configuration files or mastering means of finding them is an invaluable skill.

In Linux Directory Structure, the /etc directory or its sub-directories store system related or application configuration files.

Although this is the primary location of configuration files, a few developers choose to store other configuration files in custom directories.

How To Find MySQL (my.conf) Configuration File

You can locate the the MySQL configuration file using the mysql command line tool or mysqladmin, a client for managing a MySQL server.

The following commands will display the mysql or mysqladmin help page, which includes a section that talks about the files (configuration files) from which default options are read.

In the commands below, the grep option -A displays NUM lines of trailing context after matching lines.

$ mysql --help | grep -A1 'Default options' OR $ mysqladmin --help | grep -A1 'Default options'

Find MySQL my.cnf Configuration File

Make an effort to master the MySQL administration through these helpful articles.

Читайте также:  Kali linux yandex mirror

How To Find PHP (php.ini) Configuration File

PHP can be controlled from the terminal using php command line utility, in conjunction with the -i switch which enables showing of PHP information and configurations and grep command help you to can find the PHP configuration file like so:

$ php -i | grep "Loaded Configuration File"

Find PHP (php.ini) Configuration File

Find Apache http.conf/apache2.conf Configuration File

You can invoke apache2 directly (which is not recommended in most cases) or administer it using apache2ctl control interface as below with the -V flag which shows the version and build parameters of apache2:

--------- On CentOS/RHEL/Fedora --------- $ apachectl -V | grep SERVER_CONFIG_FILE --------- On Debian/Ubuntu/Linux Mint --------- $ apache2ctl -V | grep SERVER_CONFIG_FILE

Find Apache Configuration File

That’s all! Remember to share your thoughts about this post or provide us other possible ways of locating the above configuration files in the comments.

Источник

How to list all configuration files for an already installed package?

I am running Ubuntu 12.10 and, if possible, I would like to get the list of configuration files available for a given package that is already installed. I would prefer to do this using dpkg or apt if possible, but no problem if other tools such as aptitude or dselect are needed/recommended.

3 Answers 3

There’s no need to use anything other than cat , if I understood your intention correctly:

cat /var/lib/dpkg/info/.conffiles 

should give you what you’re after. For instance for package zsh:

% cat /var/lib/dpkg/info/zsh.conffiles /etc/zsh/zlogin /etc/zsh/zlogout /etc/zsh/zprofile /etc/zsh/zshenv /etc/zsh/zshrc /etc/zsh/newuser.zshrc.recommended 

Regarding a case where there’s no such file for a given package — it’s up to the package maintainer to designate certain files as configuration. If this hasn’t been done properly, you should file a bug where appropriate.

In such cases you have a couple of options.

    List files belonging to the package that are in /etc/:

apt-get source package less package-x.y.z/debian/rules 

If a given package is not having such a file .conffiles under this path, does it mean it is no using configuration files?

Not necessarily — it might be that there are indeed configuration files used by the package but the packager did not designate any files as part of the packaged application’s configuration files.

The .conffiles file will list all configuration files that ship with the package and are marked as such by the packager. An automatically-installed one that does not appear there is a packaging bug, but be aware that some files (particularly user-specific configuration in a user’s dotfiles) cannot ship with the package and can’t really be automatically located unless you already know what they are.

Читайте также:  Linux java rpm jdk

Let’s for example test the package apt to get the config file(s).

It can be tricky to understand what .conffiles you should check to see the info so I suggest using grep to find the clue.

locate *.conffiles | grep apt /var/lib/dpkg/info/apt-config-icons.conffiles /var/lib/dpkg/info/apt.conffiles /var/lib/dpkg/info/aptdaemon.conffiles /var/lib/dpkg/info/apturl-common.conffiles /var/lib/dpkg/info/libatk-adaptor:amd64.conffiles 

And to cat any of these in particular if you are interested according to Marcin’s Kaminski answer.

Another trick is to read the manual, for instance man apt will lead you to SEE ALSO section from where you can call man apt.conf where you will see the location of the config file for apt in this case: /etc/apt/apt.conf .

However, config file /etc/apt/apt.conf may not even exist. Be aware of that when searching for the config files.

In Linux config files should be inside the /etc/ directory. You may use dpkg-query -L your_package | grep etc to list all package files and directories inside the /etc/ directory.

How about dpkg -S [package-name]? Cant see it being mentioned here.

root@homehub:/# dpkg -S nginx nginx-common: /usr/share/nginx/html nginx-full: /usr/share/man/man8/nginx.8.gz libnginx-mod-http-xslt-filter: /usr/share/doc/libnginx-mod-http-xslt-filter/copyright nginx-common: /etc/logrotate.d/nginx libnginx-mod-mail: /usr/share/doc/libnginx-mod-mail/changelog.gz libnginx-mod-http-upstream-fair: /usr/share/doc/libnginx-mod-http-upstream-fair libnginx-mod-http-auth-pam: /usr/share/doc/libnginx-mod-http-auth-pam/changelog.Debian.gz libnginx-mod-http-image-filter: /usr/lib/nginx/modules/ngx_http_image_filter_module.so nginx-common: /etc/nginx/snippets libnginx-mod-mail: /usr/share/doc/libnginx-mod-mail/copyright nginx-common: /etc/nginx/snippets/fastcgi-php.conf libnginx-mod-http-xslt-filter: /usr/share/doc/libnginx-mod-http-xslt-filter/changelog.Debian.gz nginx-full: /usr/share/doc/nginx-full/copyright nginx-common: /usr/share/doc/nginx-common nginx-common: /etc/ufw/applications.d/nginx libnginx-mod-http-upstream-fair: /usr/share/doc/libnginx-mod-http-upstream-fair/changelog.gz libnginx-mod-stream: /usr/share/nginx/modules-available/mod-stream.conf nginx-common: /etc/nginx/sites-enabled libnginx-mod-http-upstream-fair: /usr/share/doc/libnginx-mod-http-upstream-fair/copyright libnginx-mod-http-subs-filter: /usr/share/doc/libnginx-mod-http-subs-filter/changelog.gz libnginx-mod-http-dav-ext: /usr/share/nginx/modules-available/mod-http-dav-ext.conf nginx-common: /etc/nginx/koi-utf nginx-common: /etc/nginx/mime.types nginx-common: /usr/share/vim/addons/syntax/nginx.vim nginx-common: /usr/share/doc/nginx-common/NEWS.Debian.gz nginx-common: /usr/share/doc/nginx-common/README.Debian nginx-full: /usr/share/doc/nginx-full libnginx-mod-mail: /usr/share/nginx/modules-available/mod-mail.conf libnginx-mod-http-auth-pam: /usr/share/doc/libnginx-mod-http-auth-pam/changelog.gz nginx: /usr/share/doc/nginx nginx-common: /etc/nginx/win-utf libnginx-mod-http-dav-ext: /usr/share/doc/libnginx-mod-http-dav-ext . 

And sometimes depending on filename structure it might be good if piped out to grep names containing «.conf»:

root@homehub:/# dpkg -S nginx |grep ".conf" nginx-common: /etc/nginx/snippets/fastcgi-php.conf libnginx-mod-stream: /usr/share/nginx/modules-available/mod-stream.conf libnginx-mod-http-dav-ext: /usr/share/nginx/modules-available/mod-http-dav-ext.conf libnginx-mod-mail: /usr/share/nginx/modules-available/mod-mail.conf libnginx-mod-http-auth-pam: /usr/share/nginx/modules-available/mod-http-auth-pam.conf nginx-common: /etc/nginx/fastcgi.conf nginx-common: /etc/init/nginx.conf nginx-common: /etc/nginx/conf.d libnginx-mod-http-subs-filter: /usr/share/nginx/modules-available/mod-http-subs-filter.conf libnginx-mod-http-geoip: /usr/share/nginx/modules-available/mod-http-geoip.conf libnginx-mod-http-echo: /usr/share/nginx/modules-available/mod-http-echo.conf libnginx-mod-http-upstream-fair: /usr/share/nginx/modules-available/mod-http-upstream-fair.conf nginx-common: /etc/init/nginx.conf libnginx-mod-http-xslt-filter: /usr/share/nginx/modules-available/mod-http-xslt-filter.conf nginx-common: /etc/nginx/snippets/snakeoil.conf nginx-common: /etc/nginx/nginx.conf libnginx-mod-http-image-filter: /usr/share/nginx/modules-available/mod-http-image-filter.conf 

Источник

Оцените статью
Adblock
detector