Mass modification of configuration files

Mass modification of configuration files


Mass changes to configuration files may be required when there are abrupt, global changes on the server.

For example, changing the IP address or removing it from the server's network interfaces. Using either the panel interface or text editor, such changes would require a lot of time and are not always reasonable or even possible.


Changes can be done via the stream editor "sed", as it allows you to find and fix recurring expressions.

sed -i "s/<old-value>/<new-value>/g" <path-to-files>


  • -i or --in-place - modify files at their location, with backups created before editing,
  • s or search - search for specific pattern,
  • g or global - replace all occurrences of foo with the new value.


Before making any configuration changes, it is recommended to check that the backups of the files being changed are up to date.


Changing Nginx web server configurations:

sed -i "s/" /etc/nginx/vhosts/*/*

When this command is executed, the value "" will be changed to "" in all files in the "vhosts" directory and its subdirectories.

In this article