How to enable/disable firewall on Ubuntu 22.04 LTS Jammy Jellyfish Linux

The default firewall on Ubuntu 22.04 Jammy Jellyfish is ufw, which is short for “uncomplicated firewall.” 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.

Additionally, ufw can be managed from a graphical interface. In this tutorial, you will learn how to enable and disable the ufw firewall on Ubuntu 22.04 Jammy Jellyfish from both command line and GUI.

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 22.04 Jammy Jellyfish
How to enable/disable firewall on Ubuntu 22.04 Jammy Jellyfish
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 22.04 Jammy Jellyfish
Software ufw
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 22.04 LTS Jammy Jellyfish Linux step by step instructions



Enable or Disable Ubuntu firewall via command line

  1. The first thing we should do is open a command line terminal and check the status of the firewall to see if it’s on or off with the following command.
    $ 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

  1. To control ufw via GUI, you need to install the gufw package with the following command.
    $ sudo apt install gufw
    
  2. After installation, search for the gufw application in the Activities menu to open it.
    Search for and open the newly installed gufw application
    Search for and open the newly installed gufw application
  3. Simply click the Status toggle button in order to turn the ufw firewall on or off. After you are satisfied with the changes, you can close the application window. Your changes will take effect immediately.
    Toggle the ufw on or off via GUI
    Toggle the ufw on or off via GUI




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 22.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. Usually, it is better to simply allow a port through the firewall.