First of all I can't detect the USB on linux using the command line. I check the directory dev and still cannot find the usb. used the df command to check the usb. I plug and typed df and then unplug and typed df again and nothing changed. We are using a server(telnet) to use the command line of linux on a windows 7 OS.

The second problem I have is how can I execute the bash script that I have made. It seems that I cant put my .sh file in /usr/bin/ I would like to make my command executable in all directories like a normal command. Sorry, im still newbie at this things. This is what I get on staying on Windows too much.

Sorry for my english. Thank you in advance.

4 Answers 4


df will only show you mounted file system. The Linux distribution you use may or may not automount USB drives.

The right method to do something in the event of insertion and removal of USB drives is using udev rules. See http://reactivated.net/writing_udev_rules.html

You may also use the lsusb command to see what is currently present on the usb bus. See: http://linuxcommand.org/man_pages/lsusb8.html

Which of these is the right for your case depends on your specifics use case.

  • 1
    The OP is self described newbie. I wouldn't expect OP to grok udev rules just yet.
    – Keith
    Mar 8, 2011 at 8:09

Since you are accessing remotely it probably won't automount since the desktop file manager on most "environments" is what mounts those media on most systems. It's unfortunate, but that's the way the "user friendly" distros make them.

First you can find out if USB is even working by running this:

/sbin/udevadm monitor

Then plug your USB disk in and out. You should see some events printed out. While in, look in /dev/disk/by-id and see if you see the device node (symlink).

If you do, then you may be able to mount it like this:

mkdir /mnt/media1
mount -t auto /dev/disk/(fullpathtodevice) /mnt/media1

you should unmount it before removing it.

You must be superuser (root) to do those, or be enabled by root and in the right groups.

Regarding your second question, the right place to put custom scripts for host-wide use is in /usr/local/bin. Again, you must be root to do that.


The correct place to put programs that are not provided with the operating system is /usr/local/bin. The /usr/local/bin directory is included in the PATH variable on most Linux distributions.


gby is correct - df will only detect mounted filesystems.

I suggest using a simple fstab rule, which I detail how to create in another answer here.

Of course, this requires you to actually mount the filesystem afterwards - your filemanager (I use pcmanfm - I know Thunar does this as well) should detect those lines in your fstab and list them as mountable. How you mount the drive is file manager-dependent, but usually involves right-clicking the icon and pressing Mount. Same goes for unmounting once you're done with the drive.

You could also do mount /dev/insert-usb-device-here/umount /dev/insert-usb-device-here

It goes without saying that you must su/sudo to root before doing these things.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy