Categories: DebianLinuxShell

How to comment out lines in configuration files on Linux

This tutorial focuses on commenting lines in a configuration file on Linux, the examples used here are from Debian 10. However they will work on any other linux distribution too. Lines get commented out do deactivate them. You can use this also to add comments to your config files to describe what you changed for later use.

Whenever you want to comment a line, put a # in an appropriate place in a file. Anything beginning after # and ending at the end of the line won't get executed.

Following are some examples,

# This is a comment line

This comments out the complete line.

This is a #comment line

This comments out only the last part of the line starting at #.

While # is the most common char to comment out lines, there are some files which use a different syntax. For example the php.ini file:

Lines in php.ini get commented out by using the ; char.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago