Most of the computer programs we use – whether office suites, web browsers or even video games – are configured via menu interfaces. It's almost the standard way we use our machines.
With some programs, however, you have to go one step further. Instead of menus, you have to edit a text file so that the software can run as desired.
These text files configure the software and are – not surprisingly – called "configuration files". If you want to expand your computer skills, you need to know what a configuration file is and how to edit one.
What are configuration files?
Before we go into the technical details, let's first define what a configuration file is.
Configuration files are essentially editable text files that contain information that is necessary for the successful operation of a program. The files are structured in a certain way and formatted so that they can be configured by the user.
While some configurations are hard coded in the software, settings that you can change are contained in configuration files.
Surprisingly, there is no defined standard for how configuration files should work or how they should look. It is entirely in the mood of the program developer.
Linux users are particularly familiar with configuration files because you have to edit them for many basic maintenance tasks. Optimize the Raspberry Pi
3 ways to edit the boot / config.txt file on Raspberry Pi
often relies on editing configuration files. This can be to specify a wireless network to connect to or to set the RAM size for graphics.
However, configuration files are not only available for Linux. You may have to edit them on Windows or Mac OS.
How to search and edit configuration files
Some configuration files are structured in a format that corresponds to the developer's own design. Others use well-known standards for structuring data, such as:
- YAML (YAML is not a markup language)
- XML (eXtensible Markup Language)
Some programs load the information stored in their configuration files at startup. In the meantime, others regularly check the configuration file to see if it has changed.
Regardless of which configuration file you want to edit, it is a good idea to make a copy of it before making any changes. This way you can restore the copy and start again if something goes wrong!
Now let's look at a real configuration file. As already mentioned, they come in different shapes and sizes. A configuration file that you are almost certain to be familiar with is the hosts file. Windows, Mac, and Linux all use this to manually map hostnames to IP addresses.
Windows configuration files
Windows users can find the hosts file in c: windows system32 drivers etc .
You can open it by double-clicking the mouse and selecting Notepad from the list of suggested apps. This is all you need to view and edit configuration files like hosts. However, there are several alternatives available – see below for details.
When the file is open, you'll notice that spaces (literally spaces and tabs) are used to separate items.
Each host name has its own line, followed by a tab and the IP address. In addition, the user can add annotations and comments in the hosts file, all of which start with a hash symbol.
Linux configuration files
On Linux you will find the hosts file in /etc/. This can be opened in Gedit or a command line text editor like nano or vim. In most cases, one or all of these components are preinstalled in your Linux distribution.
Some programs save the configuration file in the home directory with a period at the beginning of the file name. These configuration files sometimes have the file extension .rc and are called "point files".
Configuration files in macOS
As with Linux, the hosts file is in /etc/ on macOS.
Mac users know that BBEdit is the default pre-installed text editor. This makes it ideal for editing configuration files in macOS. As with Linux, however, the command line editors vim and nano are also available.
Apps for securely editing configuration files
So now we know what configuration files are used for. Let's talk about how we can work on them.
You need a text editor for this. Avoid word processing programs. These can add formatting to the file that would prevent them from being read correctly.
As already mentioned, native text editors are available. However, third-party text editors are also available for additional features:
Download: Notepad ++ for Windows (free)
Download: Atom for Windows, MacOS, Linux (free)
Download: Sublime Text Editor for Windows, MacOS, Linux (free evaluation)
There are so many text editing tools available for each platform that it is difficult to recommend a single app. Linux users can also check our list of Linux text editors
7 best Linux text editors and Gedit alternatives
. Meanwhile this summary of text editors for macOS
The best HTML text editors for your Mac
should help Apple computer owners.
When editing a configuration file, it is imperative that you follow the conventions. This can be worked out by simply looking at it. Some configuration files, such as the hosts file, explain these conventions in commented lines. Others force you to read some documentation or blog posts.
If the configuration file you are editing is in JSON or XML format, consider using a text editor with syntax highlighting. Notepad ++ and Atom are both good options here. Highlighting the syntax improves your accuracy by showing when you make a mistake.
Other places where you can find configuration files to edit
If you want to further examine configuration files, you can find them in all possible applications and platforms. There is more to configure than specifying which websites and IP addresses to block!
In addition to the hosts file, you will find configuration files in video games. These are often used to define and control things like keymappings.
In the meantime, some configuration files can be used to defraud. This was the case in the original Deus Ex game on the PC. Nowadays, cheating is much more difficult and often not worth the effort unless an official fraud mode is activated.
Web applications also use configuration files for customization.
What happens if your configuration editing doesn't work?
Problems with editing configuration files can be divided into two areas: permissions and user errors.
Problems with configuration files caused by permission problems are due to system integrity. You cannot save changes because you are editing as a normal user. To avoid accidental misconfigurations, many configuration files can only be edited by users with administrator rights.
Fixing this is easy:
- In Windows, right-click the text editor and choose Execute as administrator
- On macOS and Linux, try expanding your permissions with the sudo command. So once you've edited your hosts file, run it sudo nano / etc / hosts
(Note that if you specify a different file name or location, you would effectively create a configuration file in the terminal.)
If the problem is a user error, it means that it's your fault. Make sure that you have not made any typing errors and that you have followed the conventions of the configuration file.
Although it appears obvious, a simple spelling mistake can render your entire file unusable. Before you make any changes and save the file, consider the following:
- Check the change made
- Make sure you left a comment
Be sure to close the configuration file before trying to run the software you want to configure.
Configuration files are important
They are more than important and an essential part of using Linux. Knowing how to properly edit them can help a lot.
While you can edit many configuration files, you need to make a copy of the file before making changes. This way you can go back to the original if something gets shaky.
Are you using Linux? Learn more about changing and managing the hosts file on Linux here
How to change and manage the hosts file on Linux