How to Enable or Disable Firewall on Ubuntu 24.04, 22.04 or 20.04

This guide will demonstrate how to enable or disable the firewall on Ubuntu 24.04, 22.04, or 20.04 using command-line instructions, as well as how to install GUFW (Graphical Firewall UI) for those desktop users who prefer to manage UFW without delving into CLI commands.

Understanding the process of enabling or disabling the firewall on Ubuntu, be it for desktop users or system administrators on Ubuntu servers, is vital in maintaining network security. Here’s why mastering these skills is important:

  • Enhanced Security: Properly configuring your firewall is key to protecting your system from unwanted access and potential security threats.
  • Customized Control: Knowing how to handle firewall settings allows for tailored security measures that fit specific needs and scenarios.
  • System Optimization: Efficient firewall management can help optimize system performance by regulating network traffic.
  • Risk Management: Being able to swiftly enable or disable firewall settings is crucial during troubleshooting and mitigating network-related issues.

Now, let’s proceed with how to enable or disable the firewall on your Ubuntu server or desktop with just a few simple commands.

Check UFW Firewall Status on Ubuntu

To begin, Ubuntu newcomers should launch the command terminal. This can be accessed by navigating to the top right-hand corner, selecting Activities, then Show Applications, and finally Terminal.

Terminal Icon in Ubuntu for UFW ManagementPin
Terminal icon in Ubuntu Linux for enabling or disabling UFW

Once the terminal is open, you can determine the current status of your UFW (Uncomplicated Firewall) by executing the following command:

sudo ufw status

An example of what you might see after running this command is shown below:

UFW Firewall Status Inactive on Ubuntu LinuxPin
Screenshot depicting UFW firewall status as inactive on Ubuntu Linux

This output indicates that the firewall is inactive. It’s important to note that Ubuntu, by default, does not activate the firewall in new installations.

Enable UFW Firewall on Ubuntu

Enabling the UFW (Uncomplicated Firewall) on Ubuntu is a crucial step in securing your system. By default, enabling UFW will block all incoming connections while allowing all outgoing connections.

Precaution for Remote Access

If you are a server user or remotely connected via SSH, it’s essential to add rules to UFW before activating it. This step ensures you don’t lose access to your server. Execute the following command to allow SSH:

sudo ufw allow ssh

Note: Desktop users unfamiliar with SSH can skip this step.

Example Output:

joshua@ubuntu-linux:~$ sudo ufw allow ssh
Rules updated
Rules updated (v6)

Activating the Firewall

Now, proceed to enable the UFW using the command below:

sudo ufw enable

Example Output:

Enabling SSH and UFW on Ubuntu LinuxPin
Allowing SSH and Enabling UFW Firewall on Ubuntu

Verifying Firewall Status

After enabling UFW, it’s good practice to verify its status. Use the following command to check:

sudo ufw status

Example Output:

For users who allowed SSH access, you will see it listed under the ‘Action’ column.

Active UFW Status on Ubuntu LinuxPin
Screenshot showing active UFW firewall status on Ubuntu Linux

Detailed Firewall Status

For a more comprehensive view, including default policies and logging levels, use:

sudo ufw status verbose

Example Output:

This detailed view confirms that the default settings are to deny incoming and allow outgoing connections.

Detailed UFW Status on Ubuntu LinuxPin
UFW status verbose command output on Ubuntu Linux

Disable UFW Firewall on Ubuntu Linux

In the event you need to disable your UFW firewall, use the following command:

sudo ufw disable

Example Output:

Disabling the firewall will cease all its operations and remove the security measures previously set.

Disabling UFW Firewall on Ubuntu LinuxPin
Command output for disabling UFW Firewall on Ubuntu Linux

Install UFW Firewall GUI on Ubuntu

Installing GUFW

For Linux beginners who prefer not to use the terminal extensively, installing a graphical interface for UFW (Uncomplicated Firewall) simplifies firewall management. You can install GUFW, a user-friendly GUI for UFW, with the following command:

sudo apt install gufw

Accessing GUFW

After installing GUFW, access it by navigating to the top left-hand corner of your screen, selecting Activities, and then Show Applications. In the application menu, look for Firewall Configuration.

GUFW Application Icon on Ubuntu LinuxPin
Icon to launch GUFW for easy firewall management in Ubuntu

Using GUFW Interface

With GUFW, you can easily enable or disable the UFW firewall. The GUI provides a straightforward toggle for this, as demonstrated in the image below, showing the firewall status as ‘off’:

GUFW Interface on Ubuntu LinuxPin
GUFW application open on Ubuntu for firewall settings

Managing Firewall Settings

GUFW offers an intuitive interface to manage various aspects of your firewall. You can:

  • Adjust default settings for incoming and outgoing connections.
  • Check the current status of the firewall.
  • Create custom firewall rules.
  • View logs and reports.

This graphical interface makes firewall management more accessible and less daunting for users who are not comfortable with command-line operations.


Throughout this guide, we’ve navigated the essentials of managing your firewall on Ubuntu, such as how to enable or disable UFW, covering versions 24.04, 22.04, and 20.04. Whether you’re comfortable with command-line magic or prefer the graphical simplicity of GUFW, you now have the tools to keep your system secure. Remember, regularly checking and updating your firewall settings is key to maintaining robust security.

Leave a Comment

Your Mastodon Instance
Share to...