Published March 11, 2018 by

Enable and Disable USB Port in Linux

Nothing is safe in Cyberworld. Even a safe and secure Linux OS like Ubuntu can be hacked in less than 5 minutes. One of the things which we wanted to implement in endpoint protection was to disable the USB port. While Linux is almost secure from viruses, data theft can occur by means of a removable media.
In this tutorial, we will see a quick way to disable USB ports in Ubuntu.

Method 1:

Open Terminal (Ctrl + T) and insert below command

# chmod 000 /media/                                     (FOR DISABLE USB)

# chmod 777 /media/                                     (FOR ENABLE USB)

The above chmod is nothing but change mode which is a part of UNIX/Linux code mainly used for read or write permission that can be represented by numbers.

Method 2:

Add a new single line in /etc/modprobe.d/blacklist.conf file. You can use the following command like this:

# sudo echo "blacklist usb-storage" >> /etc/modprobe.d/blacklist.conf

From next time onwards, no one will be able to use the USB ports.


To re-enable the use of USB port, remove the added line from blacklist.conf.