Maybe someday you need to shutdown or activate the firewall in your mac, and only have access to the command line, then these are the commands to be used.
To check the current status :
sudo defaults read /Library/Preferences/com.apple.alf globalstate
The result will print one of these numbers;
0 = de-activated
1 = on for specific services
2 = on for essential services
if you want to shut it down :
sudo defaults read /Library/Preferences/com.apple.alf globalstate -int 0
PS. Mac OS X comes with an even more powerful Firewall than the one in the system preferences. Open up the Terminal and type “man ipfw” to learn more about it. ;) enjoy
and to turn on for the specific services :
sudo defaults read /Library/Preferences/com.apple.alf globalstate -int 1
The password requested is your own password, and you have to have administrator access to the mac.
This was tested successfully on 10.6.2 (Snow Leopard).
PS. Mac OS X comes with an even more powerful Firewall than the one in the system preferences. Open up the Terminal and type “man ipfw” to learn more about it. :) enjoy