How to delete a UFW firewall rule on Ubuntu / Debian Linux

To delete a UFW firewall rule on Ubuntu or Debian Linux, you can use the ufw command with the delete option.

For example, if you want to delete a rule that allows incoming traffic on port 22 (SSH), you can use the following command:

sudo ufw delete allow 22

Alternatively, you can also use the rule number to delete a rule. To get the rule number, you can use the ufw status numbered command.

For example, to delete the rule with number 3, you would use the following command:

sudo ufw delete 3

You can also delete multiple rules at once by specifying multiple rule numbers or ranges of rule numbers.

It is important to note that these commands will delete the rule immediately and permanently. Be sure that you want to delete the rule before running these commands.

Leave a Comment