In all operating system we are able to enable or disable hardware by configuring them. We can do same in Linux system from control center. In this blog we are going learn how to disable USB drive with the help of Linux file system. To do this we must know the file system used by Linux. Because Linux uses file to configure every hardware connected to it. We get all driver files in /dev directory. The programming module of every driver is located at /sys/modules. From this module we are able to configure hardware changing in programming module. To disable the USB we have to look for USB module in same directory.
USB module is located at /sys/modules/usbcore, from this module we are able to configure the USB device. We can get all information of USB. This module contain all information regarding USB such as speed, buffer-size, version number, etc. There are lot of files that can be configured, but to do this we require root authority. We are able to read files from normal account but can not edit them. Now let's check our USB version number: Open file “/sys/module/usbcore/drivers/usb:usb/usb2/version”.
USB module is located at /sys/modules/usbcore, from this module we are able to configure the USB device. We can get all information of USB. This module contain all information regarding USB such as speed, buffer-size, version number, etc. There are lot of files that can be configured, but to do this we require root authority. We are able to read files from normal account but can not edit them. Now let's check our USB version number: Open file “/sys/module/usbcore/drivers/usb:usb/usb2/version”.
Figure1. Version of USB |
OK now if you want to disable complete that means all usb ports to be blocked then edit file “/sys/module/usbcore/drivers/usb:usb/usb2/authorized ”. There is file contain value “1”, to disable replace it by 0. Now check your USB device is disabled.
Figure2.USB Files location |
Otherwise there is another method to replace the current digit by using following command:
root@Ravikumar[rvkmr]#sudo echo 0 | cat >> /sys / module /usbcore //drivers //usb\:usb/usb2/authorized
Result of this is your USB port is disabled. Now to enable USB, just replace bit 0 by 1 by editing file or by replacing 0 bit in above command by 1.
Result of this is your USB port is disabled. Now to enable USB, just replace bit 0 by 1 by editing file or by replacing 0 bit in above command by 1.
Figure3.Command to Enable/ Disable USB |
No comments:
Post a Comment