Commenting out/Uncommenting a Line in a Debian Configuration File

Like all UNIX-type operating systems, Linux stores the initial/default settings and configuration parameters for its programs in the form of configuration files. These files are used to configure software applications, server processes and operating system settings for your system. As a Linux administrator, you can edit these files in several ways; one of them is to comment or not comment on a configuration line.

When you open a configuration file, you may see one or more lines beginning with the ‘#’ symbol, which means that the line has been commented out. When the interpreter reads the contents of a configuration file, it ignores lines beginning with the ‘#’ character. Therefore, any line that activates a function that has been commented out means that the corresponding function is disabled on your system.

This is what an enabled (uncommented) feature looks like in a configuration file

# This is an enabled feature

FeatureEnable= true

This is how a disabled(commented) feature looks in a configuration file:

# This is a disabled feature

#FeatureEnable = true

In this article, we will present an example and see how commenting and uncommenting a line or more can be used to enable or disable a feature on your Linux System. We will run this example on a Debian 10 Buster system to enable Automatic Login for a user through the daemon.conf file located at /etc/gdm3/

Example: Enabling Automatic Login for a Debian User

Let us make use of this commenting and uncommenting feature to enable automatic login for a user on Debian.

Open the Debian Terminal through the Application Launcher search as follows:

Debian Terminal

Open the daemon.conf file in the Nano editor through the following command:

$ sudo nano /etc/gdm3/daemon.conf

Please note that you need to be a superuser to edit most of the system configurations.

When you enter your password, the following file will open:

Edit Configuration file

You can see that the highlighted lines have been commented out. It means that the automatic login feature for user1 has been disabled.

You can simply remove the # character from the last two lines we have selected and provide the username instead of the value “user1” for the user whose automatic login you want to enable. For example:

Enabled config file section

You can see the change in color of the enabled feature.

Now save the file by pressing Ctrl+X and then Y.

Now when you restart the computer, you will be logged in without being asked to provide authentication details.

We have seen how to uncomment a line to enable a feature or function. You can disable a feature, in a similar manner, by adding a # character at the start of a feature-defining line.