Security and Privacy: Mac Terminal Commands for a Safer System

In this digital age, security and privacy are of utmost importance. As a Mac user, you have access to a powerful tool called the Terminal, which allows you to execute commands to enhance the security of your system. In this article, we will explore some essential Mac Terminal commands that can help you create a safer environment.

1. Enable Firewall

The Mac firewall acts as a barrier between your computer and potential threats from the internet. To enable it, open Terminal and enter the following command:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on

This command will activate the firewall and protect your Mac from unauthorized incoming connections.

2. Disable Automatic App Termination

Mac's automatic app termination feature may force open applications to close without your consent. To prevent this from happening, use the following command:

defaults write -g NSDisableAutomaticTermination -bool TRUE

With this command, you can ensure that your apps stay open until you manually close them, enhancing both security and convenience.

3. Enable Stealth Mode

By enabling the stealth mode, you can make your Mac invisible on the network, preventing potential attackers from discovering your computer's presence. Execute the following command:

sudo defaults write /Library/Preferences/ stealthenabled -bool true

Enabling stealth mode adds an extra layer of protection to your system by not responding to unwanted network queries.

4. Implement Stronger Secure Empty Trash

When you delete files, they aren't permanently erased from your hard drive. Instead, they are moved to the Trash. By using the following command, you can enhance the secure empty trash function, making sure that deleted files cannot be recovered:

defaults write EmptyTrashSecurely -bool true

With this command, the "Empty Trash" function will securely delete files by overwriting them, making data recovery nearly impossible.

5. Disable Bonjour

Bonjour is a network protocol that allows devices to discover each other on a local network. While it can be useful, it also poses a potential security risk. To disable Bonjour, use the following command:

sudo defaults write /System/Library/LaunchDaemons/ ProgramArguments -array-add "-NoMulticastAdvertisements"

By disabling Bonjour, you reduce the chances of unauthorized devices discovering your computer on the network.

6. Enable FileVault

FileVault is a built-in encryption feature in macOS that ensures the security of your data. To enable FileVault, run the following command:

sudo fdesetup enable

This command will prompt you to enter your administrator password and create a recovery key, which you should carefully store in case you forget your login password.


Taking steps to enhance the security and privacy of your Mac is crucial in today's digital landscape. By using the powerful Mac Terminal commands mentioned in this article, you can create a safer system environment. However, always remember that Terminal carries considerable power, so exercise caution and thoroughly understand the commands before executing them. Stay vigilant and protect your Mac from potential threats.

Mac Commands

Master your Mac with ease with our ultimate command reference.