What is a config file? How to safely edit the config file?

Software configuration text files are called config files (configuration files). If you want to improve your computer's knowledge, you will need to know what the config file is and how to edit it.

Most of the computer programs we use, whether it's Office suites, web browsers, or even video games, are configured via menu interfaces, and this is almost always the way. default to use everything.

But some programs require you to go beyond that. Instead of menus, you have to edit a text file so that the software runs as you wish.

These text files configure the software and are called config files (configuration files). If you want to improve your computer's knowledge, you will need to know what the config file is and how to edit it.

What is a config file?

Before digging deeper, let's determine what the config file is.

The configuration files are basically editable text files, containing the information needed for the program to work successfully. The files are structured in a specific way and formatted for users to configure.

Although some configurations are hard coded into the software, the settings that you can change are included in the configuration files.

Surprisingly, no standard has been defined on how the configuration files work or what they look like. Everything completely depends on the interests of the program developer.

Picture 1 of What is a config file? How to safely edit the config file?
There is no standard defined how the configuration files work or what they look like

Linux users will be particularly familiar with configuration files, since many basic maintenance tasks require editing them. The process of tweaking a Raspberry Pi, such as assigning a wireless network to connect or setting the amount of RAM for graphics, often relies on editing the config file.

However, the configuration file is not specific to Linux. Sometimes you may have to edit them in Windows or macOS.

How to find and edit the config file

Some config files are structured in the developer's own design format. Other files use widely known standards, used to structure data, such as:

  1. JSON (JavaScript Object Notation)
  2. YAML (YAML Ain't Markup Language)
  3. XML (eXtensible Markup Language)

Some programs load information stored in the configuration file when they launch. Meanwhile, other programs only periodically check the configuration file to see if it has been changed.

Any configuration file you want to edit is smart enough to make a copy, before any changes are made. This way, if something goes wrong, you can restore the copy and start over!

Now let's look at a configuration file in the real world. As mentioned earlier, they come in all types and sizes. A configuration file that you are almost certainly familiar with is the hosts file. Windows, Mac and Linux all use this file to manually map IP addresses to hostnames.

Windows configuration file

Windows users will find the hosts file in C: windowssystem32driversetc.

You can open the hosts file by double-clicking and selecting Notepad from the list of suggested applications. This is all you need to view and edit the configuration files like the hosts file. However, there are several alternatives available (see details below).

When you open the file, you'll see that it uses spaces to separate elements.

Picture 2 of What is a config file? How to safely edit the config file?
Each hostname has a unique line

Each hostname has its own line, followed by a stop tab and an IP address. The hosts file also allows users to add comments and comments, all starting with the # symbol .

Linux configuration file

On Linux, you will find the hosts file in / etc /. This file can be opened in Gedit or a command line editor like Nano or Vim. In most cases, your Linux distribution will have one or all of these tools pre-installed.

Some programs store configuration files in the home directory, with a period at the beginning of the file name. These configuration files sometimes have the .rc file extension and we call them dotfiles.

Configuration file in macOS

Like Linux, the hosts file can be found in / etc / on macOS.

Mac users will know that BBEdit is the default, pre-installed text editor. This makes it ideal for editing configuration files in macOS. However, as with Linux, Vim and Nano command line editors are also available.

Application to edit config files safely

Now you know what the configuration files are used for. Next, learn how to fix them.

To do this, you will need a text editor. Avoid using a regular document creation tool, as they can add formatting to the file, making it impossible to read correctly.

Picture 3 of What is a config file? How to safely edit the config file?
When you edit a configuration file, it is very important to follow the conventions

The original editor is available, as mentioned. However, to add additional functions, a third-party text editor is also available:

  1. Notepad ++ for Windows (Free)
  2. Atom for Windows, Atom for macOS, Atom for Linux (Free)
  3. Sublime Text Editor for Windows, Sublime Text Editor for macOS, Sublime Text Editor for Linux

When you edit a configuration file, it is very important to follow the conventions. Some configuration files, such as the hosts file, will explain the convention for you in the comment lines. Other files will force you to read some documents, or some blog posts.

Finally, if the configuration file you edit is in JSON or XML format, consider the editor that features syntax highlighting. Notepad ++ and Atom are both good options here. Syntax highlighting improves accuracy by specifying when you make mistakes.

Update 22 May 2020
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile