Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: December 16, 2021
The ability to tweak Linux exactly as we need makes it powerful to use. While most distributions offer sophisticated interfaces for configuring the system, these UIs just modify plaintext config files spread across the system. So, understanding these config files will remove our dependence on these UIs and make us more proficient with Linux.
In this tutorial, we’ll see where these files are located and what they do. Thanks to the Filesystem Hierarchy Standard, the directories and files discussed in this tutorial should be consistent across distributions.
The global configuration files define the behavior for the entire system.
These files are usually located in the root (/) partition and require superuser access.
Most global config files are located in the /etc directory.
The /etc/ directory feels more like a filesystem and has many sub-directories, each having related config files.
The following is a list of the most useful of these sub-directories:
The /etc/opt/ directory is supposed to contain global configuration for applications installed inside /opt/. But, Linux does not enforce this. As a result, we can often see /opt/ directory full of user-installed software while /etc/opt/ remains empty.
The config files under /etc/default/ historically contained settings for services/daemons for use with initialization systems such as upstart. But, with the advent of systemd, this directory now mainly contains settings for userland applications.
The system does not overwrite files inside /etc/default/. This means that once we define application behavior here, they will stay consistent through system upgrades.
Some of the most useful global config files are:
User-specific config files modify system behavior only for the user who has defined it.
These files usually reside inside a user’s home directory and don’t require superuser permissions for modification.
One thing to note is that user-specific configs always have higher precedence than global configs. Thus, an application will always prefer a user-specific config as long as it exists.
When it comes to user-specific configurations, we have applications following two standards.
Traditionally, if an application had a single config file, it would be stored at /home/<username>/.<app_name{rc}>. But, if there were more than a single file, the configs would be stored inside the directory /home/<username>/.<app_name>.
A prime example of this behavior is the vim editor.
freedesktop.org decided the old system was messy and developed the XDG base directory specification.
As per the XDG standard, all user-specific config files are stored inside the $XDG_CONFIG_HOME directory (usually /home/<username>/.config).
Inside $XDG_CONFIG_HOME, each application creates its own sub-directories to store configs.
The NeoVim editor and many actively developed applications now follow the XDG base directory specification. This is also very convenient for users as backing up the single $XDG_CONFIG_HOME directory saves all configs.
Some of the most commonly used user-specific config files are:
In this article, we learned the two types of config files available in Linux and where we can find them.
Also, we went through commonly used directories for storing configurations and how older and newer applications handle user-specific configs.
Since Linux does not enforce a specific format for these config files, their syntax can vary wildly. But, if we are willing to spend a bit of time and effort, config files can free us from the limitations of UIs targeted at novice users.