Solved firewall-cmd command not found
Enjoying this content? Subscribe to the Channel!
Quick Fix: Resolving the ‘firewall-cmd not found’ Error by Installing Firewalld
Hey Tech Fans, and welcome back to Darren’s Tech Tutorials!
If you’ve recently spun up a new Linux server (especially on RHEL or CentOS-based systems) and tried to configure your firewall settings, you might have run into a brick wall. Specifically, you try to use the firewall-cmd utility only to be greeted with an error message indicating that the command cannot be found or executed.
Don’t panic! This is one of the most common issues new system administrators face, and the solution is incredibly simple. The error isn’t a bug; it’s a dependency issue. The tool you are trying to use is missing the engine it needs to run.
In this quick tutorial, we’ll walk through the four essential commands needed to install, enable, and start the firewalld service, getting your system secure and your firewall-cmd utility running immediately!
Why Are You Seeing This Error?
The primary reason you cannot run the firewall-cmd command is that the underlying daemon, firewalld, is not installed on your system.
Think of it this way:
firewall-cmdis the remote control (the command-line interface) you use to send instructions.firewalldis the television (the actual service) that executes those instructions and manages the netfilter kernel rules.
If the TV isn’t installed, the remote control has nothing to talk to! We need to install the core service first.
The 4-Step Fix: Installing and Enabling Firewalld
These steps assume you are running a Red Hat-based distribution (like CentOS, Fedora, or RHEL) that uses the yum or dnf package manager, and you have sudo privileges.
Follow these four simple commands in order to get the service up and running:
Step 1: Install the firewalld Package
The first step is to fetch the necessary files and install the service onto your operating system. We use sudo yum install firewalld for this process.
sudo yum install firewalld
After confirming the installation, the necessary packages will be downloaded and installed onto your server.
Step 2: Start the firewalld Service Immediately
Once the files are installed, the service is not automatically running yet. You need to start it up so it can begin managing your firewall policies right away. We use systemctl to control the service.
sudo systemctl start firewalld
Step 3: Enable Firewalld on System Boot
This is a crucial step! If you skip this command, your firewall service will stop the next time you reboot the server, leaving your system unsecured. Enabling the service ensures that firewalld launches automatically every time the system starts up.
sudo systemctl enable firewalld
You should see a message confirming that a symbolic link has been created, linking the service to the system’s startup routines.
Step 4: Verify the Service Status
Finally, let’s confirm that the service is running correctly. Run the status command to ensure the service is loaded and active.
sudo systemctl status firewalld
You should see output confirming that the firewalld service is Active (running).
Conclusion: You Are Now Ready to Configure Your Firewall!
Congratulations! You have successfully installed and enabled the firewalld service.
By performing these four quick steps, you’ve secured your system and fixed that annoying “command not found” error. You can now proceed to use the firewall-cmd utility to open ports, manage zones, and fully secure your server environment.
Go ahead, try running your favorite firewall-cmd instructions now!
If this tutorial saved you time and frustration, please take a moment to hit the Like button on the video, subscribe to Darren’s Tech Tutorials for more crystal-clear guides, and drop a comment below letting us know what technology challenge we should tackle next! Keep coding, and stay secure!