How to Fix “firewall-cmd: command not found” Error in RHEL/CentOS 7

firewall-cmd is a command line front-end for firewalld (firewalld daemon), a dynamic firewall management tool with D-Bus interface.

It supports both IPv4 and IPv6; it also supports networks firewall zones, bridges and ipsets. It allows for timed firewall rules in zones, logs denied packets, automatically loads kernel modules, and so many other features.

Firewalld uses runtime and permanent configuration options, which you can manage using firewall-cmd. In this article, we will explain how to solve “firewall-cmd: command not found” error on RHEL/CentOS 7 Linux systems.

Read Also: Useful ‘FirewallD’ Rules to Configure and Manage Firewall in Linux

We encountered the above error while trying to configure firewall rules on a newly launched AWS (Amazon Web Services) EC2 (Elastic Cloud Compute) RHEL 7.4 Linux instance, as shown in screenshot below.

firewall-cmd: command not found
firewall-cmd: command not found

To fix this error, you need to install firewalld on RHEL/CentOS 7 using yum package manager as follows.

$ sudo yum install firewalld
Install FirewallD in RHEL 7
Install FirewallD in RHEL 7

Next, start firewalld and enable it to auto-start at system boot, then check its status.

$ sudo systemctl start firewalld
$ sudo systemctl enable firewalld
$ sudo systemctl status firewalld
Start and Enable FirewallD
Start and Enable FirewallD

Now you can run firewall-cmd to open a port (5000 in this example) in the firewall like this, always reload firewall configurations for the changes to take effect.

$ sudo firewall-cmd --zone=public --add-port=5000/tcp --permanent
$ sudo firewall-cmd --reload
Open Port in FirewallD
Open Port in FirewallD

To block the above port, run these commands.

$ sudo firewall-cmd --zone=public --remove-port=5000/tcp --permanent
$ sudo firewall-cmd --reload

You might also like to read these useful firewalld guides:

  1. How to Start/Stop and Enable/Disable FirewallD and Iptables Firewall in Linux
  2. How to Configure FirewallD in CentOS/RHEL 7
  3. Useful ‘FirewallD’ Rules to Configure and Manage Firewall in Linux
  4. Firewall Essentials and Network Traffic Control Using FirewallD and Iptables
  5. How to Block SSH and FTP Access to Specific IP and Network Range in Linux

In this article, we have explained how to solve “firewall-cmd: command not found” on RHEL/CentOS 7. To ask any questions or share some thoughts, use the comment form below.

If this article helped, with someone on your team.

TecMint Weekly Newsletter
Get the Learn Linux 7 Days Crash Course free when you join 34,000+ Linux professionals reading every Thursday.
Check your email for a magic link to get started.
Something went wrong. Please try again.
TecMint has been free for 14 years. Help keep it that way.
Google AI Overviews and tools like ChatGPT have cut into search traffic for independent tech sites like TecMint. Running this site costs over $2,000 every month for hosting, infrastructure, and paying authors to keep the content accurate and tested.

If this article helped you solve a problem, consider buying a coffee. It helps keep TecMint free, supports the authors, and keeps the project going.
☕ Buy Me a Coffee
Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

2 Comments

Leave a Reply
  1. I’m getting this error when checking the status of firewalld:

    ERROR: Exception DBusException: org.freedesktop.DBus.Error.AccessDenied: Connection “:1.11” is not allowed to own the service “org.fedoraproject.FirewallD1” due to security policies in the configuration file

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Free Course
Get a free Linux course before you go.
Subscribe to TecMint Weekly and get the Learn Linux 7 Days Crash Course free. Read by 34,000+ Linux professionals every Thursday.
Something went wrong. Please try again.
Check your email for a magic link to get started.