How to enable/disable firewall on Ubuntu 20.04 LTS Focal Fossa Linux

The default Ubuntu firewall is ufw, which is an acronym for “uncomplicated firewall.” It comes automatically installed on all editions of Ubuntu Desktop and Ubuntu Server. Ufw is a frontend for the typical Linux iptables commands, but it is developed in such a way that basic firewall tasks can be performed without the knowledge of iptables. You may find you need to disable ufw if it is blocking some necessary connections, or you can enable it for increased security.

Additionally, ufw can be managed from a graphical interface. In this tutorial, you will learn how to enable and disable firewall on Ubuntu 20.04 LTS Focal Fossa Linux from both command line and GUI. Note that it is ordinarily best to leave ufw enabled, so it can protect your system.

In this tutorial you will learn:

  • How to check firewall status
  • How to enable/disable firewall
  • How to control firewall settings from GUI
How to enable/disable firewall on Ubuntu 20.04 LTS Focal Fossa
How to enable/disable firewall on Ubuntu 20.04 LTS Focal Fossa

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Installed or upgraded Ubuntu 20.04 Focal Fossa
Software ufw (uncomplicated firewall)
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to enable/disable firewall on Ubuntu 20.04 LTS Focal Fossa Linux step by step instructions



DID YOU KNOW?
It is not usually necessary to disable ufw firewall. Rather, you can open or allow a connection in ufw so that you do not need to disable the firewall entirely. You should only disable it on a test system or if you plan to manually keep track of firewall rules using iptables or some other frontend.
  1. The first thing we should do is check the status of the firewall to see if it’s on or off.
    $ sudo ufw status
    Status: active
    

    As seen here, our firewall is currently active (on). For more detailed output regarding your current firewall settings, add the verbose option.

    $ sudo ufw status verbose
    
  2. To disable the Ubuntu firewall, execute the following command.
    $ sudo ufw disable
    
  3. If you decide you need to enable the Ubuntu firewall again later, you can run the following command.
    WARNING
    Please note that by enabling your firewall you may get disconnected if you are currently using SSH to remotely connect to your Ubuntu server.
    $ sudo ufw enable
    

Enable or Disable Ubuntu firewall via GUI

To control ufw via GUI, you need to install the gufw package with the following command.

$ sudo apt install gufw

Then, start the gufw application and click on the Status switch to either enable or disable the firewall. See the video below for more help.



How to enable/disable firewall on Ubuntu Linux

Closing Thoughts

In this tutorial, you learned how to enable or disable the system firewall (ufw) in Ubuntu 20.04. You also saw how to check the current status of the firewall. Normally, you will not need to disable the firewall unless for testing purposes or something similar. If you need to allow a port through the firewall, see our tutorial on how to Open/Allow incoming firewall port on Ubuntu 20.04.