How to Disable USB ports, CD-ROM and Floppy drives in Ubuntu

User Avatar
👤 admin
🔴 Admin
✍️ The most important thing in the world is to not be alone.
⏳ Last active: 15 Apr 2025 at 16:01
📅 Created: 19 Feb 2021 at 12:10
👀 Viewed: 21 times
✉️ Send Email

In the company where I work, the employees often had to work from their homes during the pandemic. This necessitated the need to encrypt these laptops, and then to the question of how to stop all USB ports and CDs. In this article, we will look at some simple but effective methods to disable USB ports, CD drives and floppies.

But in the end, why do we need all this?
Well, often people, without even realizing it, can forget their laptop unlocked in a cafe and a conscientious person can quickly download a few key files or do a bunch of other nonsense. Therefore, in some cases, locking all communication ports on the laptop would increase your corporate security.

So what to do for usb ports. There is a very simple command that will help us in this case.


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

To enable the usb ports plese go to blacklist.conf and remove the line at the bottom of the file blacklist usb-storage or just comment it.

Now for the CD-ROM just a reminder for all of this commands you have to be as root..


eject -i 1

chmod 000 /cdrom

chmod 000 /media

Eject command will disable the cd-rom physical button. To restore it use eject -i 0

It's a simple solution but it works perfectly.

And for the floppy drive


chmod 000 /dev/fd0

In conclusion, we could say that the time consuming for this whole operation is no more than two minutes and the headache that we could save from possible theft of information is staggering.

Also it's good to know that most modern laptops have the options to lock usb ports and cd drives from the BIOS and also you can password protect the BIOS!
:)

Also if you are using a virtual server like ESXI or Hyper-V you can remove the devices from the virtual machine settings.

https://youtu.be/HwqFwRzssJk

If you want to comment: Login or Register