Updated: 28 September 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9

Configuration files often contain more comments than settings. These commands show only the active lines. They work on any Linux system.

Hide comments and empty lines

grep -Ev '^\s*(#|$)' /etc/ssh/sshd_config          # files that use # comments
grep -Ev '^\s*(;|$)' /etc/php/8.3/cli/php.ini      # PHP uses ; (on AlmaLinux/Rocky: /etc/php.ini)
grep -Ev '^\s*(#|;|$)' /etc/my.cnf.d/server.cnf     # both kinds

See the settings that are really in effect

Several programs can print their complete active configuration, including defaults and included files. This is more reliable than reading one file:

sshd -T                    # OpenSSH
nginx -T                    # Nginx
apachectl -S                # Apache virtual hosts (httpd -S on AlmaLinux/Rocky)
php -i | grep memory_limit  # PHP (command-line settings)
mariadbd --print-defaults   # MariaDB options from config files

Tip: Before editing a configuration file, copy it: cp -a file file.bak.

Save a clean copy

To compare your settings with another server or with the defaults, write the active lines to a file and use diff:

grep -Ev '^\s*(#|$)' /etc/ssh/sshd_config > /tmp/sshd.active
diff /tmp/sshd.active /tmp/sshd.other-server

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket