Delete a ufw rule on Ubuntu 20.04 the safe way: list the rules numbered, pick the right one and remove it without dropping the rest of your firewall.

List existing firewall rules

To delete firewall rules from UFW, we first need to get a numbered list of the rules that are currently configured. Open a terminal and enter the following command to list all the rules:

$ sudo ufw status numbered

Remove a firewall rule

Take note of the number that corresponds to the firewall rule you’d like to delete. In our example, we’re going to delete rule #2, which allows connections over HTTPS (port 443) on IPv4. The following command deletes rule #2:

$ sudo ufw delete 2

After running that command, you’ll be asked to confirm that you want to delete the rule. Just enter y and press enter to continue. Now that it’s been deleted, you can check UFW’s list of rules once again to make sure that the rule no longer appears:

$ sudo ufw status numbered
Was this answer helpful? 3 Users Found This Useful (6 Votes)