Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to comment out multiple lines in a Linux config file?

Given:

code

in /etc/nginx/sites-available/mySite.conf. We know that

#Code

means it will get ignored. But how if I want to comment out:

Code
Code
Code
Code

without using # ? I have people see use ''' in python to comment out multiple lines. Does this work for Linux config files as well?

like image 797
stevek-pro Avatar asked Nov 05 '14 20:11

stevek-pro


People also ask

How to add comments to a config file in Linux?

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. This comments out the complete line.

How do I comment out a line in Linux?

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.

How do I uncomment a line in a configuration file?

You can “uncomment a line” in a configuration file by removing the # at the start of the line. Or, to “comment out” a line, add a # character to the start of the line. (Note that some languages have different comment formats, so this may not be true if you’re working with a source code file.)

Why should I ignore all comment lines in a file?

One reason to ignore all comment lines is to see relevant config settings of any particular conf file. As an example /etc/hdparm.conf contains 137 lines.


1 Answers

There's no standard "Linux config file" -- the syntax is totally dependent on what program is reading the file and how that program is parsing it.

Nginx recognizes only lines beginning with # as comments. http://nginx.org/en/docs/beginners_guide.html#conf_structure

like image 131
Dan Rice Avatar answered Nov 02 '22 22:11

Dan Rice