---
updatedAt: 2025-08-14T18:11:22.000Z
agentTools:
  siteIndex: https://developer.n-able.com/llms.txt
  projectIndex: https://developer.n-able.com/n-central/llms.txt
---

# Linux - USB Device Report

```shell Shell Script
#!/bin/bash

# Parses /sys/bus/usb/devices/usb for devices/products that match the $MANIFEST
# To generate a manifest, download and run "Linux-Make-USB-Manifest.sh" on a machine with the desired devices connected
# Or run /usr/bin/usb-devices and compile the list of device Vendor IDs and Product IDs into the following format:
# MANIFEST="VendorID1,ProductID1 VendorID2,ProductID2 [...] VendorIDn,ProductIDn"

MANIFEST=$*
INVENTORY=""
MISSING=""
ERRORS=0

if [ -z $MANIFEST ]
then
	echo "A list of VendorID,ProductID objects is required."
	exit 1002
fi	


# List all the current USB devices and check vendorID and productID against $MANIFEST
for devicePath in /sys/bus/usb/devices/*
do

        if [ -f $devicePath/bDeviceClass ]
        then
#	echo $devicePath
# if the path includes a device, it will have a device class.
# check for "hub" class == "09" and skip
        deviceClass=`cat $devicePath/bDeviceClass`
#       echo $deviceClass

	# for each item found, check if it's in the manifest
	        if [ $deviceClass != "09" ]
	        then
	            	vendorID=`cat $devicePath/idVendor`
	                productID=`cat $devicePath/idProduct`
	                INVENTORY="${vendorID},${productID} ${INVENTORY}"

		        if [[ ! " ${MANIFEST[*]} " =~ " ${vendorID},${productID} " ]]
       			then
				echo "Not in MANIFEST: $USBITEM"
				((ERRORS++))
        		fi

		fi

	fi
done


# for each item in MANIFEST, determine if it exists in INVENTORY
for USBITEM in $MANIFEST
do

	if [[ " ${INVENTORY[*]} " =~ " ${USBITEM} " ]]
	then
		echo "Found: $USBITEM"
	else
		MISSING="${USBITEM} ${MISSING}"
		echo "MISSING: $USBITEM"
                ((ERRORS++))
	fi
done

# if everything is present, log success and exit 1000
# otherwise, log missing item, exit nonzero

if [ $ERRORS != 0 ]
then 
	ERRORS=1001
fi

exit $ERRORS
```

```json Response Example
{"success":true}
```

# SCRIPT