On Friday, August 10, 2012 10:19:54, Michael Quick wrote:
> I'm not that sophisticated, I guess something like this will have to do:
> 
> egrep "sd[b-e]|Mounted" /var/log/messages  | egrep -v -i
> "installing|cache|error|write" | more

I inserted a vfat formatted USB stick, mounted it, unmounted it, and removed 
it, then ran the above command.  My system gives me this:

Aug 10 11:45:04 trelane kernel: sd 6:0:0:0: [sdb] 3981312 512-byte logical 
blocks: (2.03 GB/1.89 GiB)
Aug 10 11:45:04 trelane kernel: sdb: sdb1
Aug 10 11:45:04 trelane kernel: sd 6:0:0:0: [sdb] Attached SCSI removable disk
Aug 10 11:46:03 trelane kernel: sdb: detected capacity change from 2038431744 
to 0

[I don't have a USB drive with NTFS or ext[34] on it to be able to test the 
prior commands you sent.]

> On Fri, Aug 10, 2012 at 9:37 AM, Michael Quick 
<[email protected]>wrote:
> > Thanks for responding!  Basically I was looking to get a history of who
> > has plugged in a USB drive to machine X.

The log shows that a USB device was attached, but (probably) can't tell you 
who did it.

> > What does this return on your
> > system ? Notice FAT drives will not be found, I'm not sure how to search
> > for them yet.  I also noticed that keyring spits out messages as well and
> > I could try to use that.
> > 
> > less messages* | egrep "ntfs-3g" | grep "Mounted"
> > less messages* | grep "EXT[3-4]" | grep "sd[b-c]" | grep "mounted"
>
> > On Thu, Aug 9, 2012 at 8:46 PM, Chris Knadle 
<[email protected]>wrote:
> >> On Thursday, August 09, 2012 17:34:20, Michael Quick wrote:
> >> > Hi,
> >> > 
> >> >     In a bash script I want to list all of the USB drives that have
> >> >     been
> >> > 
> >> > connected to my system. Anyone have a clue on the best way to do this
> >> > ?
> >> 
> >> It depends on what you're looking for.
> >> 
> >> 'lsusb' can list USB devices, but that will only get you a device ID.
> >> 
> >> If what you're looking for is a device you can *mount* then I suggest
> >> looking
> >> under /dev/disk/<subdirs> which is the area where udev.  Within there
> >> are
> >> 
> >> several subdirectories:
> >>    /by-label/   -> you can mount devices by drive label
> >>    /by-uuid/    -> you can mount by filesystem UUID
> >>    /by-path/    -> you can mount device partitions by path
> >>    /by-id/      -> you can mount filesystems by device ID
> >>   
> >>   -- Chris
> >> 
> >> --
> >> Chris Knadle
> >> [email protected]
> >> _______________________________________________
> >> Mid-Hudson Valley Linux Users Group                  http://mhvlug.org
> >> http://mhvlug.org/cgi-bin/mailman/listinfo/mhvlug
> >> 
> >> Upcoming Meetings (6pm - 8pm)                         Vassar College
> >> 
> >>   Sep 5 - OpenStack
> >>   Oct 3 - Mobile Web Development
> >>   Nov 7 - Typography: Physical Art to Digital Art

  -- Chris

--
Chris Knadle
[email protected]
_______________________________________________
Mid-Hudson Valley Linux Users Group                  http://mhvlug.org
http://mhvlug.org/cgi-bin/mailman/listinfo/mhvlug

Upcoming Meetings (6pm - 8pm)                         Vassar College
  Sep 5 - Towards an Open Cloud with OpenStack
  Oct 3 - Mobile Web Development
  Nov 7 - Typography: Physical Art to Digital Art

Reply via email to