a2dismod
Quick Reference
Command Name:
a2dismod
Category:
web server
Platform:
linux
Basic Usage:
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 apache2Be cautious when disabling modules that others may depend on
Use
a2enmodto re-enable modules if neededCheck for syntax errors after disabling modules:
sudo apache2ctl configtestCore 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-utilspackage on Debian/Ubuntu systems
Tips & Tricks
Use the -q option to run in quiet mode
Use the -a option to disable all modules
Use the -M option to specify a module to be disabled
Use the -m option to specify a module to be disabled
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
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
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.