This script helps to monitor changes in USB devices connected to your system. It runs the lsusb
command before and after a USB device is plugged or unplugged, and then shows the differences.
You need the lsusb
command to be installed on your system.
You can install usbutils which includes lsusb however this sometimes only returns the device ids with no description
brew install lsusb
Most Linux distributions come with lsusb
pre-installed. If you don't have it, you can install it using your package manager.
sudo apt update
sudo apt install usbutils
sudo yum install usbutils
sudo pacman -S usbutils
- Download or copy the
compare_usb.sh
script. - Make the script executable by running:
chmod +x compare_usb.sh
- Run the script:
./compare_usb.sh
Follow the on-screen instructions to plug or unplug a USB device and press Enter
when ready. The script will show the differences between the initial and final states of USB devices.
To run the script from any directory, you can add it to your PATH.
- Move the script to a directory that is in your system's
PATH
, or create a directory for user scripts:
mkdir -p ~/bin
mv compare_usb.sh ~/bin/
- Add
~/bin
to yourPATH
if it's not already included. Edit your~/.bashrc
or~/.bash_profile
:
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
- Reload your terminal configuration:
source ~/.bashrc
Now you can run compare_usb.sh
from anywhere by typing compare_usb.sh
in the terminal.
This project is released under the GNU GENERAL PUBLIC LICENSE.