a2dismod

web serverlinux
The a2dismod command is one of the most frequently used commands in Linux/Unix-like operating systems. a2dismod The a2dismod command is used to disable Apache2 modules. It removes symbolic links from the /etc/apache2/mods-enabled directory that were previously created by a2enmod. After disabling modules, Apache needs to be restarted to apply the changes.

Quick Reference

Command Name:

a2dismod

Category:

web server

Platform:

linux

Basic Usage:

a2dismod [options] [arguments]

Common Use Cases

  • 1

    Apache module disablement

    Disable Apache modules to remove functionality

  • 2

    Web server configuration

    Configure the Apache web server

  • 3

    Scripting

    Use in shell scripts to automate module disablement

  • 4

    Performance

    Optimize web server performance

Syntax

a2dismod [OPTION]... [MODULE]...

Options

Option

Description

-q, --quiet

Quiet mode; suppress informational messages

-m, --maintmode

Disable the module in maintenance mode (for a specific Apache instance)

-f, --force

Force disabling the module, ignoring dependency issues

-p, --purge

Purge all traces of the module from the config

-h, --help

Display help information

Examples

How to Use These Examples

The examples below show common ways to use the a2dismod command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

Basic Examples: # Disable a single module sudo a2dismod rewrite # Disable multiple modules at once sudo a2dismod ssl headers # Disable a module and restart Apache sudo a2dismod proxy && sudo systemctl restart apache2 # Check if a module is already disabled sudo a2dismod -q rewrite && echo "Module is disabled" || echo "Module is not disabled" Advanced Examples: # Disable a module for a specific Apache instance sudo a2dismod -m apache2-custom rewrite # Force disabling a module even if other modules depend on it sudo a2dismod -f proxy_http # List all enabled modules before disabling ls /etc/apache2/mods-enabled/*.load | cut -d. -f1 | sed 's/.*///' # Disable all modules (dangerous, use with caution) for mod in $(ls /etc/apache2/mods-enabled/*.load | cut -d. -f1 | sed 's/.*///' | grep -v "mpm_"); do sudo a2dismod $mod; done

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

Common Use Cases:

  • Disabling unused modules to improve server performance and security

  • Troubleshooting Apache configuration issues by selectively disabling modules

  • Removing unnecessary functionality to reduce the attack surface

  • Resolving module conflicts by disabling incompatible modules

  • Server optimization by removing modules that aren't required for your specific use case

Tips:

  • Always restart Apache after disabling modules: sudo systemctl restart apache2

  • Be cautious when disabling modules that others may depend on

  • Use a2enmod to re-enable modules if needed

  • Check for syntax errors after disabling modules: sudo apache2ctl configtest

  • Core modules and MPM (Multi-Processing Module) should generally not be disabled

  • The default MPM module (usually mpm_event or mpm_prefork) should always remain enabled

  • The command is part of the apache2-utils package on Debian/Ubuntu systems

Tips & Tricks

1

Use the -q option to run in quiet mode

2

Use the -a option to disable all modules

3

Use the -M option to specify a module to be disabled

4

Use the -m option to specify a module to be disabled

5

Use the -c option to specify a configuration file

Common Use Cases

Apache module disablement

Disable Apache modules to remove functionality

Web server configuration

Configure the Apache web server

Scripting

Use in shell scripts to automate module disablement

Performance

Optimize web server performance

Security

Enhance web server security

Related Commands

These commands are frequently used alongside a2dismod or serve similar purposes:

Use Cases

1

Apache module disablement

Disable Apache modules to remove functionality

2

Web server configuration

Configure the Apache web server

3

Scripting

Use in shell scripts to automate module disablement

4

Performance

Optimize web server performance

5

Security

Enhance web server security

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the a2dismod command works in different scenarios.

$ a2dismod