The Problem
Why is the below error observed when the firewall-cmd –state command is executed:
-bash: firewall: command not found
The Solution
If there is a syntax error while executing the command, one may get the error of the following sorts :-
# firewall-cmd -state usage: see firewall-cmd man page firewall-cmd: error: unrecognized arguments: -state
# firewall -cmd --state -bash: firewall: command not found
stop firewalld in CentOS/RHEL 7
The below command may be executed to stop firewall:
# systemctl stop firewalld
For Example:
# systemctl status firewalld firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled) Active: active (running) since Thu 2015-03-12 09:31:07 IST; 5h 33min ago Main PID: 814 (firewalld) CGroup: /system.slice/firewalld.service └─814 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid Mar 12 09:31:06 rhel7-server systemd[1]: Starting firewalld - dynamic firewall daemon... Mar 12 09:31:07 rhel7-server systemd[1]: Started firewalld - dynamic firewall daemon.
# firewall-cmd --state running # systemctl stop firewalld # firewall-cmd --state not running
disable firewalld in CentOS/RHEL 7
Below command may be execute to disable service (Turn the service off for the next reboot, or any other trigger.)
# systemctl disable firewalld.service
For example:
# systemctl disable firewalld.service rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service' rm '/etc/systemd/system/basic.target.wants/firewalld.service'
enable firewalld in CentOS/RHEL 7
To re enable the firewalld service again, use the below command:
# systemctl enable firewalld.service
For example:
# systemctl enable firewalld.service ln -s '/usr/lib/systemd/system/firewalld.service' '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service' ln -s '/usr/lib/systemd/system/firewalld.service' '/etc/systemd/system/basic.target.wants/firewalld.service'
Verify if firewalld is enabled or disabled in CentOS/RHEL 7
# systemctl is-enabled firewalld disabled
# systemctl is-enabled firewalld enabled