How to disable USB ports on Windows, Mac and Linux

Now, you know that using a USB storage device on your computer has many potential security risks. If you fear the risk of being infected with malware, such as trojian, keyloggers or ransomware, you should completely disable the USB storage device if the system has a lot of sensitive data. The article will show you how to disable USB ports on Windows, Mac and Linux.

Disable USB storage device: advantages and disadvantages

If you are worried about the possibility of malware infection on your computer via USB storage device, you should consider disabling this support. However, this job has certain disadvantages.

  1. 5 signs of computer infection with malware

The first drawback is that you cannot use USB storage devices on your computer. If you can use cloud memory easily, this is not a problem. However, if you need a device to exchange data regularly between two computers and cannot use cloud storage, it will be very difficult. You can look at tools like Resilio Sync to create a virtual sharing between PC computers.

If you still want to disable USB storage, the article will guide you through the steps to take on Windows 10, Mac and Ubuntu 18.04.

How to disable USB storage device on Windows

Blocking USB storage devices on Windows computers is very simple. You also have a few options; The first two solutions below are for Windows 10 Home PC.

1. Edit the Registry manually

Open the registry by pressing Win + R , then enter " regedit ".

How to disable USB ports on Windows, Mac and Linux Picture 1

Agree to User Account Control notification, then browse to HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesUSBSTOR. Here, double-click Start (or right-click, choose Modify ) and edit the value.

How to disable USB ports on Windows, Mac and Linux Picture 2

To turn off, change the value to 4. If you need to turn on the USB port again at any time, just change it back to 3, click OK when done. Note that if you are going to change the registry system, you should back up the registry to prevent a problem.

2. Create a registry script

Alternatively, you can create two blank TXT files in Notepad. To do so, launch the text editor and enter the following line:

  1. These "hack" tips are only Notepad can do
 Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesUSBSTOR] "Start"=dword:00000004 [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesUSBSTOREnum] "Count"=dword:00000000 "NextInstance"=dword:00000000 

Save the file as disableusb.reg , make sure to change the .TXT file extension to .REG, otherwise this script will not work. Next, repeat the above process and save as enableusb.reg.

For the second file, edit the line:

 "Start"=dword:00000004 

City:

 "Start"=dword:00000003 

Save the file after it's done. Now whenever you need to disable USB storage device, run the file disableusb.reg. However, any device that has been plugged into the computer will not be affected, until withdrawn. If you need to re-enable the USB storage device, use the file enableusb.reg. Saving files somewhere easy to remember can be found when needed.

Preventing others from using enableusb.reg is not too difficult, you can set up only the administrator account to run the file, as long as you do not share your profile.

3. Use Group Policy Editor

The third option available for Windows 10 Pro and Enterprise is to modify the settings for the USB storage device in Group Policy Editor.

Press Win + R to open the Run dialog box and enter " gpedit.msc ". This will open the Group Policy Editor, then expand Administrative Templates> System> Removable Storage Access . In the right pane, you will see some items that control media access on the computer. You need to activate the following three options:

  1. Removable Disks: Deny execute access
  2. Removable Disks: Deny read access
  3. Removable Disks: Deny write access

Then, double click on each item and click the Enabled button. Click OK to confirm before moving on to the next item.

Now, whenever you plug a USB storage device into your computer, you will receive an Access is denied message on Windows Explorer when trying to open the drive letter. To reverse this, change the three settings above and set to Disabled .

  1. Summary of some simple ways to disable USB ports on Windows computers

How to disable USB storage devices on a Mac

To restrict USB storage devices on a Mac, you first need to disable System Integrity Protection (SIP). Then open Utilities> Terminal and remove the driver.

Note: you should only disable this feature when necessary because many people advise you not to do so, refer to the article Why shouldn't you disable the System Integrity Protection feature on a Mac? for information.

 kextunload /System/Library/Extensions/IOUSBMassStorageClass.kext/ 

Next, open / System / Library / Extensions and rename the file (or move to a safe place) IOUSBMassStorageClass.kext . You should replace something that is easy to remember so you can easily find it when you want to re-enable the USB storage device.

How to disable USB ports on Windows, Mac and Linux Picture 3

When you're done, go back to Terminal and enter:

 sudo touch /System/Library/Extensions 

This removes the cache files, forcing the build back without reference to the renamed file. Now, you cannot access USB storage devices when connecting.

How to disable USB storage device on Linux

Need to block a USB storage device on your computer? To do this, open Terminal and use the mv (move) command to 'hide' the USB driver:

 sudo mv /lib/modules/ $( uname -r) /kernel/drivers/usb/storage/usb-storage.ko /home/user1 

Now, when plugged into the USB storage device, it will not work. In short, you cannot access this device. However, this change will no longer work in the case of a kernel update.

Although USB storage devices and portable flash can be password protected, it cannot prevent thieves from stealing your data. The only real solution is USB access control. When staying at home you need to make sure no one accesses your computer without your permission and should lock it when not in use. In the workplace, limit the number of users accessing USB to be manageable.

See more:

  1. Disable USB drives, CD-ROM, Floppy Disk and LS-120 with Group Policy
  2. Summary of some ways to fix USB Device Not Recognized on Windows 7, 8 and 10
  3. 12 USB drives can keep your data safe
3.6 ★ | 22 Vote

May be interested

  • Run Windows applications on Linux, macOS and other platformsPhoto of Run Windows applications on Linux, macOS and other platforms
    you can dual boot on linux or use bootcamp or parallels on mac. if not, you can install the following applications we suggest. these applications will allow you to install and run windows applications directly on non-windows operating systems, for example: mac os x, gnu / linux, ubuntu, bsd and solaris.
  • 6 best code editor apps for MacPhoto of 6 best code editor apps for Mac
    whether you are a script writer or a black hat hacker, a programmer or professional code writer, you need a code editor application. if you choose to program on a mac instead of windows, here is a list of the best code editing tools you should use.
  • Top download acceleration software for MacPhoto of Top download acceleration software for Mac
    download accelerator plus is also known as dap, which is the most popular download manager software of all time. however, it stopped supporting macos x 10.4 and above. if you need to download large files, check out the top management software, speed up downloading for the following mac.
  • 7 tips on OS X for Windows usersPhoto of 7 tips on OS X for Windows users
    os x is still customizable for easier use by default, but unfortunately, you have to make some manual changes to improve everything on this operating system.
  • How to run macOS on Windows 10 in a virtual machinePhoto of How to run macOS on Windows 10 in a virtual machine
    even if you are a loyal fan of microsoft and windows, it doesn't mean you can't use another operating system on windows. and the best way to do that is to use your current operating system and a virtual machine. in this tutorial, i will show you how to run macos on windows in a virtual machine.
  • How to turn off self-extracting files on macOS SafariPhoto of How to turn off self-extracting files on macOS Safari
    the safari browser on macos has the ability to automatically extract files, without having to do it manually. however, if you want to turn off auto-extracting files on macos safari, how do you do it?