Sometimes a ufw rule list is past saving. Duplicates from old scripts, and an allow rule nobody can explain. I’d rather start clean than delete them one by one, and ufw reset does exactly that.
sudo ufw reset
ls /etc/ufw/*.rules.*
The man page says it disables the firewall and resets it to the installation defaults. It asks for confirmation first, and when you run it over SSH the prompt warns that it may disrupt existing SSH connections. --force skips the question, which I’d only use in a script.
What I like is that it doesn’t throw anything away. Before copying the default files into place, ufw renames your current rule files with a timestamp, so /etc/ufw/user.rules becomes something like /etc/ufw/user.rules.20261127_143005, and the same happens to before.rules, after.rules and their IPv6 versions. The output lists every backup it made. If you change your mind, those files are still there to compare with or copy back.
The caveat is the order of things on a remote server. After a reset ufw is disabled and every rule is gone, including the one for SSH. Your current session usually survives, but don’t run ufw enable again until you’ve added the SSH rule back:
sudo ufw allow OpenSSH
sudo ufw enable
Also note that a reset puts back the default before.rules, so any hand edits in there (a NAT block, a ping rule) are gone from the live config too. They’re only in the timestamped copy now.
Further reading: ufw manual page (Ubuntu), ufw source on Launchpad