Published February 16, 2018 by

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

Firewalld uses runtime and permanent configuration options, which you can manage using firewall-cmd

In this tutorial, I will explain how to solve "firewall-cmd: command not found" error on RHEL/CentOS 7.

To fix this error, we need to install firewalld
 sudo yum install firewalld  

Now, start firewalld service and enable it to auto-start at system reboot.
 # sudo systemctl start firewalld  
 # sudo systemctl enable firewalld  
 # sudo systemctl status firewalld  

Open/Close Port

Firewall rule settings are managed by firewalld service daemon. A command-line client called firewall-cmd can talk to this daemon to update firewall rules permanently.

Open port

For Example, To open a port TCP/443 permanently, use following commands.
 # firewall-cmd --zone=public --add-port=443/tcp --permanent  
 # firewall-cmd –reload  

Close above port

 # firewall-cmd --zone=public --remove-port=443/tcp --permanent  
 # sudo firewall-cmd --reload  

Adding and Removing Services in Firewalld

By default, firewalld comes with pre-defined services, if we want to add any specific services so need adds using the command. like ftp, ssh, etc...

For example, the following commands will add or remove SSH services.
 # firewall-cmd --zone=public --add-service=ssh  
 # firewall-cmd --zone=public --remove-service=ssh  
 # firewall-cmd --zone=public --list-services  

For example, the following commands will add or remove FTP services.
 # firewall-cmd --zone=public --add-service=ftp  
 # firewall-cmd --zone=public --remove-service=ftp  
 # firewall-cmd --zone=public --list-services