How to Manually Edit ufw Rules on Ubuntu Linux

By | 2012/08/25

ufw is the great command line app for managing iptables in Ubuntu. While any changes should use the ufw command, it is possible to rather manually edit user created ufw rules in cases where that might be desirable.

The file location is:


For ipv6 rules, the file is:


As with iptables, rules are processed in the order of the file top to bottom. For example this first rule would be processed before the one following:

### tuple ### deny any any any in
-A ufw-user-input -s -j DROP

### tuple ### allow any 80 any in
-A ufw-user-input -p tcp --dport 80 -j ACCEPT

After making changes, reload ufw:

$ sudo ufw reload

4 thoughts on “How to Manually Edit ufw Rules on Ubuntu Linux

  1. Cinto

    Hi this is working but is doesn’t show on

    sudo ufw status

    also if we disable and enable ufw, the rule will get deleted.

    any work-around ?

  2. Arty

    In the latest version of Ubuntu the rules are in /etc/ufw/user.rules


Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.