Here is the interesting tweak about how to disable usb storage device in linux, and only root / sudo users can alone enable / mount it from the terminal. Using the below tweak / method one can block normal / guest user from mounting the usb storage device.

Follow the steps

1) Add this line “blacklist usb_storage” to the end of /etc/modprobe.d/blacklist.conf

To add : Open a Terminal by using Ctrl+Alt+T or Applications->Accessories->Terminal. You need to have root access to do this tweak. Copy and paste the following command in the Terminal. Type the password for the user, when prompted.

sudo gedit /etc/modprobe.d/blacklist.conf

The above command will open the blacklist.conf file in gedit. You can use any editor to edit this file like vim, gvim, emacs etc., Now copy and paste this line “blacklist usb_storage” at the end of the file. After adding this save it and close the gedit. Check the below screen shot.

2) Add this line “modprobe -r usb_storage” before exit 0 in /etc/rc.local

To add : Copy and paste the following command in the Terminal. Type the password for the user, if prompted.

 sudo gedit /etc/rc.local

The above command will open the rc.local file in gedit. Now copy and paste this line “modprobe -r usb_storage” before the last line of the file. After adding this save it and close the gedit. Check the below screen shot for Fedora and Ubuntu.

For Ubunntu:

For Fedora:

Now restart your system.

To Mount USB device

Open a Terminal and use the following command. Type the password for the user, when prompted.

sudo modprobe usb_storage

To Unmount the USB device

Use “safely remove drive” by right click on the device, then run the below command in the Terminal. Type the password for the user, when prompted.

sudo rmmod usb_storage

Hope this will be helpful for you!!

Related Posts Plugin for WordPress, Blogger...