Pinterest Stumbleupon Whatsapp
Ads by Google

The vast majority of the computer programs we use — be they office suites, web browsers, or even video games — are configured through a system of menu interfaces. It has almost become the default way we use our machines. But some programs require you to take a step beyond that, and you actually have to edit a text file in order to get them to run as you wish.

These text files are — unsurprisingly enough — called “config files”. If you want to take the leap from “user” to “power user”, you’re going to need to know how to tweak them.

What Are Config Files?

Before we get into the technical nitty-gritty, let’s first concretely define what a configuration file is.

Config files are essentially files that contain information required for the successful operation of a program, which are structured in a particular way. Rather than being hard-coded in the program, they are user-configurable, and are typically stored in a plaintext file (although I have previously seen programs that have used SQLite databases Learn SQL Or Create A Simple Database With SQLite Database Browser Learn SQL Or Create A Simple Database With SQLite Database Browser Have you ever found yourself in need of a database, but you can't really afford Microsoft Access, and you certainly can't afford to install and operate an Oracle server at home. Whether your goal is... Read More as their config files).

Surprisingly, there’s no defined standard on how config files should work, or what they should look like. It’s entirely up to the whim of the developer of the program.

Some config files are structured in a format of the developer’s own design. Others use widely-known standards used to structure data, like JSON (JavaScript Object Notation), YAML (YAML Ain’t Markup Language) or XML (eXtensible Markup Language) format. Some programs load the information stored in their config files when they start, while others periodically check to see if it has been changed.

Ads by Google

ConfigJSON

If you’re a Linux user, you’re probably going to be familiar with these, as many basic maintenance tasks require you to edit config files. If you want to tweak GRUB to dual-boot your system How To Dual-Boot The Windows & Linux OS's On Your Computer How To Dual-Boot The Windows & Linux OS's On Your Computer It's like having two computers in one - start your system up and choose between Windows and Linux. It's called dual-booting, and it gives you access to two of the best operating systems on the... Read More , or set up a web server How To Set Up An Apache Web Server In 3 Easy Steps How To Set Up An Apache Web Server In 3 Easy Steps Whatever the reason is, you may at some point want to get a web server going. Whether you want to give yourself remote access to certain pages or services, you want to get a community... Read More , you’re going to have to deal with them.

Although it’s not an exclusively Linux thing. Depending on what you’re doing, you might have to edit them in Windows or Mac OS X.

What Do Config Files Look Like?

Now, let’s take a look at some real-world config files. As we mentioned earlier, they come in all different shapes and sizes. One config file you’re almost certainly familiar with is the hosts file, which is used on Windows, Mac, and Linux to manually map IP addresses to hostnames.

Hosts

On Windows, you can find it under c:\windows\system32\drivers\etc\hosts. On Mac and Linux, it’ll be in /etc/hosts.

As you’ll notice, the hosts file uses whitespace to separate elements, with each hostname having its own line. Furthermore, the hosts file allows the user to add annotations and comments, which all begin with a hash symbol.

vim-vundle-code

On Linux and Mac OS X, some programs require the user to store the config file in the home directory, with a period at the beginning of the filename. These config files sometimes have the file extension .rc, and are colloquially called “dotfiles”.

One program which follows this particular convention is the Vim text editor The Top 7 Reasons To Give The Vim Text Editor A Chance The Top 7 Reasons To Give The Vim Text Editor A Chance For years, I've tried one text editor after another. You name it, I tried it. I used each and every one of these editors for over two months as my primary day-to-day editor. Somehow, I... Read More . In the past, we’ve talked about how to customize VIM by editing its config file Vim Is Awesome: Make It Better With These 5 Customizations Vim Is Awesome: Make It Better With These 5 Customizations Text editors might not be sexy, but they are important. One of the most powerful Linux text editors is VIM (short for, Vi Improved), and here we show you how to extend its functionality further. Read More .

Config files are even used by video games to define and control some of the behavior, such as keymappings. The config file below is taken from Black Mesa — a fan-made remake of the original Half Life.

BlackMesa

In the original Deus Ex, which was released in 2000, the user actually had to edit the config file to enable cheats!

How to Edit Config Files

So, now we know what config files are used for, let’s talk about how we can edit them.

To do this, you’re going to need a text editor. Don’t use a word processor, as these can add formatting to the file which would prevent them from being read by the program.

Windows users already have a text editor pre-installed. I’m talking about Notepad. Although it’s worth stressing that there are a number of great third-party text editors available for Windows, including Notepad++, Atom, and Sublime Text Editor.

AtomHosts

On Linux, the closest analog to Notepad is Gedit gedit: One Of The Most Feature-Filled Plain Text Editors [Linux & Windows] gedit: One Of The Most Feature-Filled Plain Text Editors [Linux & Windows] When you think of plain text editors, the first thing that may pop into your head is Windows' Notepad application. It does exactly what its job description states - plain features for a plain text... Read More . You also might want to consider using a command-line text editor, like Nano or Vim nano vs. vim: Terminal Text Editors Compared nano vs. vim: Terminal Text Editors Compared Although Linux has become easy enough for practically anyone to use without ever having to use the Terminal, there are some of us who regularly use it or are curious about how one can control... Read More . For the sake of sheer efficiency, I heavily lean towards the Vim text editor. This makes it easy for me to precisely jump to different positions within the config file, simply by using just a handful of keystrokes.

On Mac OS X (or MacOS Sierra, is it will soon be known What's New in macOS Sierra? The New Features Coming to Your Mac What's New in macOS Sierra? The New Features Coming to Your Mac OS X is dead, long live macOS. Read More ), there are a number of text editors that come pre-installed. You’re probably familiar with TextMate. It also includes a number of command-line text editors, like Vim and Nano.

When you edit the file, it’s important to ensure you follow the conventions of it. This can be worked out just by looking at it. Some config files, like the hosts file, will explain these conventions to you. Others will force you to read some documentation, or a couple of blog posts.

Finally, if the config file being edited is structured in a JSON or XML format, you might want to use a more powerful text editor with syntax highlighting. I recommend Atom. This will improve your accuracy by showing you when you’ve made a mistake.

What If It Isn’t Working?

Finally, let’s touch on what happens when things go wrong. In my own experience, the problems associated with editing config files tend to fall into two camps.

The first is permissions. If you’re unable to save your changes, it could be because you’re trying to do it as an ordinary user. In order to prevent accidental damage, many config files are only editable by those with administrator-level privileges.

Fixing this is easy. On Mac and Linux, try escalating your privileges with the sudo command. So, if you were editing your hosts file, you’d run:

sudo nano /etc/hosts

On Windows, right-click Notepad (or whatever text editor you’re using) and select Run as administrator.

NotepadRunAsAdmin

The second common problem is user error. If things aren’t working, it might be your fault. Check that you haven’t made any typos, and that you’ve followed the conventions of the config file. It does sound obvious, I know, but a simple spelling mistake, or forgetting to close a pair of speech marks can render your entire file useless.

A good way to avoid problems is to make a copy of the config file before you make any changes. This way, if something goes wrong, you can restore the copy and start again!

Config Files Are Important

More than important, they’re an essential part of using Linux. Knowing how to properly edit them can help you endlessly.

Are there any other essential skills you feel that beginner-to-intermediate Linux users need to know? Let me know in the comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *