Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Disable USB Ports on Mac

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

You can disable USB ports on a Mac by using built-in parental controls (Screen Time) to restrict USB accessories, or by using Terminal commands to disable the USB controller entirely. The quickest method is via System Settings > Privacy & Security > USB Accessories, but for a full block, you'll need Terminal. This guide covers both approaches, plus third-party options for advanced control.

What You'll Need

  • An administrator account on the Mac (you'll need to enter your password).
  • For the Terminal method: basic comfort with command-line commands.
  • For the parental controls method: the Mac must be running macOS Catalina or later (Screen Time is available from Catalina onward).
  • Optional: a third-party USB blocking app (paid) if you need per-port control or scheduled blocking.

Step-by-Step

Method 1: Restrict USB Accessories via Screen Time (Simplest)

  1. Open System Settings (or System Preferences on older macOS).
  2. Click Screen Time in the sidebar.
  3. If you haven't used Screen Time before, click Turn On. You may need to set a Screen Time passcode if prompted (remember it!).
  4. Scroll down and click Content & Privacy (or look for a tab named “Content & Privacy”).
  5. Enable the Content & Privacy toggle at the top if it's off.
  6. Click USB Accessories (this option appears only when Content & Privacy is on).
  7. Choose Allow USB Accessories or Ask for permission. To disable USB ports entirely, choose Ask for permission – this will prompt for a password every time a new USB device is connected, effectively blocking unauthorized use. If you want to block all USB devices, you can also choose Don't allow if available (on some versions, the options are “Allow” and “Ask”).
  8. Close System Settings. The setting takes effect immediately.

Method 2: Disable USB Controller via Terminal (Full Block)

  1. Open Terminal (found in /Applications/Utilities/).
  2. Type the following command and press Enter: sudo kextunload /System/Library/Extensions/IOUSBFamily.kext
  3. Enter your administrator password when prompted. This unloads the USB driver, disabling all USB ports immediately.
  4. To re-enable USB ports, type: sudo kextload /System/Library/Extensions/IOUSBFamily.kext and press Enter.
  5. After unloading, USB devices will not work until you reload the kext. Note: This method is not persistent across reboots – you'll need to repeat it after restarting your Mac.

Method 3: Use a Third-Party App (Advanced Control)

  1. Search the Mac App Store for “USB blocker” or “USB lock” apps. Examples include “USB Lock” or “Port Locker”.
  2. Download and install the app of your choice (ensure it's from a reputable developer).
  3. Open the app and grant it necessary permissions (usually via System Settings > Privacy & Security > Accessibility or Full Disk Access).
  4. Configure the app to block specific ports, schedule blocking times, or require a password for USB access.
  5. Follow the app's instructions to activate the block.

Common Mistakes

  • Forgetting the Screen Time passcode: If you set a passcode and forget it, you'll need to erase the Mac or use a backup to reset it.
  • Using the wrong Terminal command: The kext command is specific to macOS. On newer macOS versions (Monterey and later), the path may be different; check with kextstat to see if IOUSBFamily is loaded.
  • Not realizing the Terminal method is temporary: After a reboot, USB ports will work again unless you re-run the command.
  • Expecting per-port control with Screen Time: Screen Time blocks all USB accessories, not individual ports. For per-port control, you need third-party software.
  • Disabling USB while using a USB keyboard/mouse: If you unload the USB driver, your USB keyboard and mouse will stop working, possibly leaving you unable to interact with the Mac. Use a Bluetooth keyboard/mouse or the built-in keyboard/trackpad if available.

Tips

  • Before disabling USB, ensure you have a way to interact with the Mac (e.g., Bluetooth keyboard/mouse, or the built-in keyboard/trackpad on laptops).
  • If you only want to block data transfer but allow charging, use the Screen Time method with “Ask for permission” – it blocks data but still allows charging (on some devices).
  • For a persistent block across reboots, consider creating a launch daemon that runs the kextunload command at startup. However, this requires creating a plist file and may need SIP disabled – which is not recommended for most users.
  • Test the setting with a USB flash drive to confirm it works as expected.
  • If you're using the Terminal method, write down the re-enable command somewhere safe so you don't get stuck.

Troubleshooting

USB devices still work after enabling Screen Time restriction: Make sure you've enabled “Content & Privacy” and selected “Ask for permission” or “Don't allow” under USB Accessories. If the option is grayed out, ensure you're logged in as an administrator. Also, check that the Mac is not in a “trusted” state for the device – you may need to disconnect and reconnect the device to trigger the prompt.

Terminal command fails with “No such file or directory”: This can happen on newer macOS versions where the kext path has changed. Try using sudo kextunload -b com.apple.iokit.IOUSBHostFamily instead. If that also fails, check if the kext is loaded with kextstat | grep USB.

After unloading the USB driver, the Mac becomes unresponsive: If you're using a USB keyboard/mouse, you'll lose input. Restart the Mac by holding the power button, then re-enable the driver using the kextload command after boot. To avoid this, use a Bluetooth input device or the built-in keyboard/trackpad.

Screen Time passcode forgotten: You can reset it by going to System Settings > Screen Time > Change Passcode, but you'll need to enter the old passcode. If you truly forgot it, you'll need to erase the Mac and restore from backup (or set up as new).

Third-party app doesn't block USB: Ensure the app has the necessary permissions (Full Disk Access, Accessibility). Also, some apps may not work on the latest macOS due to security changes – check the developer's website for updates.

Frequently Asked Questions

Will disabling USB ports affect charging?

With the Screen Time method, charging may still work because the Mac can provide power without data. With the Terminal method, USB ports are completely disabled, so charging will also stop.

Can I disable only specific USB ports?

macOS does not offer built-in per-port control. You'll need third-party software that can identify and block individual ports, but this is rare and may not work reliably.

Does the Screen Time restriction apply to all users?

Yes, if you enable it in Screen Time with a passcode, it applies to all users on the Mac. If you don't set a passcode, it applies only to the current user.

Will the Terminal method survive a reboot?

No, the kextunload command is temporary. After restarting, USB ports will work again unless you re-run the command or set up a launch daemon.

Is there a way to disable USB ports on a Mac without admin rights?

No, both methods require administrator privileges. If you don't have admin access, you'll need to ask the system administrator to do it.

Can I use a physical USB blocker instead?

Yes, you can buy USB port blockers (small plastic inserts) that physically prevent inserting cables. This is a simple, non-software solution, but it doesn't block data if someone removes the blocker.