UFW is already installed on Ubuntu 18.04. You can verify it from here
$ which ufw /usr/sbin/ufw
$ ufw enable
$ ufw disable
$ ufw reload
If you don’t receive output, you need to install UFW. Please refer the following commands. $ sudo apt-get install ufw
$ sudo ufw allow 80/tcp
Change the port which you want to open.
$ sudo ufw deny 80
Change the port which you want to deny
$ sudo ufw status
First, check the status of UFW using numbered.
$ sudo ufw status numbered
This command will show the rules with numbers
Now remove the rule using the following command(Replace the 1 with the rule number which you want to remove)
$ sudo ufw delete 1