How can I find out when a device is connected to my FreeBSD machine? Lets say I plug in a USB device, HDMI device, Bluetooth or something like that.
Can I have a console output to say [device] and gives some output about the device?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
All other answers are good, if you want only to check if a device is connected (checking kernel messages with
dmesg, check in
/var/log files and use some tools like
But, if you want more (handle a message and execute a program or something like that when you plug your device), you can use devd.
When you connect a device, FreeBSD kernel will generate messages:
attachmessage is generated
detachmessage is generated
devd.confman page if you want more information).
devd by default, and its configuration is stored in
/etc/devd.conf. If you use linux, the same features exist with
You can find some examples in
dmesg | grep -i USB will give you the list of connected
To get information about USB devices.
usbconfig can help give it a try.
pciconf -lv pciconf diagnostic utility for the PCI bus
You will always find info about new connected devices in dmesg and /var/log/messages.
For bluetooth you can check with: hcitool dev
For usb devices, try lsusb (-v).
Other useful commands: lshw (-short), hwinfo (--short) (if installed), lspci (-v), lsblk, df -h, fdisk -l, multipath -ll, mount, dmidecode, cat /proc/scsi/scsi, hdparm -i /dev/sda. There are multiple variations of these commands depending on your needs.
You can output the kernel log with
dmesg. The full log is in
/var/log/messages. There you will find information when new devices are detected or have disappeared, and log entries about some other actions.
If you want to integrate scripts or programs, you can take a look at
/etc/devd.conf (man page). This is a text file containing rules with match expressions and actions. In this way you can load modules and execute binaries/scripts when devices are registered.
lshal command will give you the DMI/SMBIOS hardware information (
dmidecode under Linux)
You can list your connected USB device through:
Also you can use the
lsusb command under FreeBSD after Installing the
usbutils package :
pkg install usbutils