Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

is it possible to log USB connect and disconnect in ubuntu 13.x? Also it will be excellent if it could log the connect/disconnect and email to some email address. Is there any program for that?

Is it possible with some scripting ? If yes please let me have an idea of doing it.

share|improve this question

Yes, it is possible to log, in fact is it already logged by the kernel as standard. And you can access it from both the dmesg and the system log. dmesg and cat /var/log/syslog. Be aware this will also send you email on reboot and startup of the system.

Wish you good luck and have fun tweaking it to perfectly suit your needs.

# Home crafted udev usb mail rule
ACTION=="add", SUBSYSTEMS=="usb", RUN+="/home/yourusername/"
ACTION=="remove", SUBSYSTEMS=="usb", RUN+="/home/yourusername/"


text="$(/bin/dmesg | /bin/grep -i 'usb' | tac)"
/bin/echo -e "Date:$(date)\n\nudev env and reversed log is embed.\n\n$(env)\n\n$text" | /usr/bin/mail -s 'Mail from udev.' -t root@localhost


sudo chmod +x /home/yourusername/
share|improve this answer
Thanks for your time. let me try and i will post any difficulties. i am a Linux starter. – niksmac Jan 20 '14 at 14:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.