Network

The firewall-cmd command

Controls firewalld (the Red Hat/Fedora firewall): ports, services and zones.

Syntax

firewall-cmd [--state|--list-all|--add-port=|--reload]

Most useful options

--stateWhether it is running
--add-port=Open a port (80/tcp)
--permanentMake the change persistent

Copy-ready examples

$ sudo firewall-cmd --stateCheck state
$ sudo firewall-cmd --add-port=80/tcpOpen HTTP

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • Without --permanent the change is lost when firewalld restarts.

Related commands

FAQ

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course