How to List and Delete UFW Firewall Rules?

The UFW is an abbreviation of the “Uncomplicated Firewall” and is used in Linux distributions to monitor the incoming/outgoing network traffic on different ports. We can also use the ufw utility to control the network traffic by allowing and restricting accessibility on different ports. Initially, the UFW rules are added (either they are for allowing or disallowing any port) and can be deleted as required.

This post will enlist the methods to list and delete UFW firewall rules in Linux, and the post’s content is as follows:

Let’s start the guide!

Prerequisites: Install and Configure UFW Utility

Before getting into details, it is assumed that your system has the UFW utility and is configured. Moreover, there must be some firewall rules set also. To install UFW, you can access the following link, which contains UFW configuration and installation steps.

How to List UFW Firewall Rules?

It is supposed that the UFW has been installed and enabled on your Linux machine. To list down all the rules which are added in the UFW, display the status of the UFW using the command:

$ sudo ufw status

All the rules are displayed on the screen, and to get more information of the rules added, use the “verbose” option as follows:

$ sudo ufw status verbose

Also, to display all the rules of the UFW with their id numbers and numeric order, use the command:

$ sudo ufw status numbered

These are the different methods by which we can list the rules of the UFW in Linux.

How to Delete UFW Rules in Linux?

Sometimes, we want to restrict the traffic on any specified port, then we have to remove the rules. To do so, we have two major methods, either by using their number or by using their port number. Here, various scenarios are demonstrated to delete UFW rules in Linux:

Delete a Rule Using Rule Number

The command provided below will delete a firewall rule set at number “3”:

$ sudo ufw delete 3

It will show the rule being deleted, and confirm the deletion using the “y” keyword.

Delete a Rule Using Rule Name

Now, the command written below will delete the rule “allow 43”:

$ sudo ufw delete allow 43

The rule has been deleted.

Delete All the Rules of UFW

To reset the UFW by deleting all the added rules, run the below-mentioned command:

$ sudo ufw reset

It will ask the confirmation before deleting the rules, which can be confirmed by typing the “y”.

Bonus Tip: How to Bypass Firewall Rules on Linux?

To bypass the firewall rules on Linux, we can disable all the set rules with the execution of the command:

$ sudo ufw disable

This will disable the Firewall on the system, and all the rules will be held on hold.

That’s all from this guide!


To list the UFW rules, run the command “sudo ufw status” in the terminal of Linux, and similarly, use either “sudo ufw delete [port number]” or “sudo ufw delete [rule number]” to delete a specific firewall rule. Moreover, the users can use the “sudo ufw reset” command to delete all the rules and reset the UFW. This post has provided all the possible methods to list and delete UFW firewall rules in Linux.