What Does the ufw enable Command Do in Ubuntu?

The ufw enable command in Ubuntu activates the Uncomplicated Firewall (UFW), a user-friendly frontend for managing netfilter firewall rules. When executed, this command boots up the firewall framework, ensures it automatically starts on system boot, and immediately begins enforcing the active security ruleset to protect the system from unauthorized network access.

Activating the Firewall and Boot Persistence

By default, UFW is installed on Ubuntu but is set to an inactive state. Running ufw enable changes this status immediately.

Enforcing Default Policies

Upon activation, ufw enable applies the standard default firewall policies if you haven’t customized them. For most standard setups, these defaults include:

Impact on Active Connections

When you run ufw enable, the system will typically display a warning message: Command may disrupt existing ssh connections. Proceed with y/n?.

If you are managing an Ubuntu server remotely via SSH, you must ensure that you have allowed SSH traffic (sudo ufw allow ssh) before enabling the firewall. If you do not create an exception for port 22 (or your custom SSH port) before activating UFW, the ufw enable command will cut off your current remote session and lock you out of the server.