Many of the Linux beginners who come from Windows know how to manage devices on their Windows systems. But unfortunately they don’t know how to do the same on Linux. This is not because Linux is any different, it is because they are new and do not know where to get the right help. Here I will help you discover and manage devices in your Linux system. I will be using the Ubuntu 20.04 distribution. All commands are valid for related distributions that use the apt package manager.
What is udev?
We use Udev as our device manager for the Linux kernel. It helps create and remove device nodes in the / dev Directory. It is Udev that allows USB devices and network drives to be connected. It helps a system administrator manage devices connected to a Linux system.
We apply rules in /etc/udev/rules.d/ Directory and Udev processes the changes as soon as a device is connected.
I will use that udevadm Tool to interact with the Udev device manager. Let’s do it.
How do you recognize a hard drive?
You can use the following command to view a lot of data related to a specific device. Hard drives usually start with / dev / sda or / dev / sdb Hence, we will also use the same format to recognize our hard drive.
$ udevadm info /dev/sda2
You will see an output like below:
This gives us a lot of information. You can see that it is showing us all the information available about our hard drive. On the last few lines of the terminal, if you notice it, you’ll notice that it shows a hard drive running under VBOX. It also shows the relatives UUID the hard drive.
Udev also allows you to change the name of your hard drive, USB devices and network cards.
For example: if you go to the rules list, you will find that there are a number of devices to update their names.
Here is a demo of the rules list file. Enter the following command and check your rules file.
$ cd /etc/udev/rules.d/
I use a Nano Text editor on my Ubuntu server, so I’m going to use the following command to open the rules file.
It is important to remember this Udevadm info starts with the device that the Developer path and then leads us to the chain of higher-level devices.
The file shows every available device. It can be deactivated, removed and renamed.
Why rename a device?
When it comes to team management, it’s better to rename a device. This helps your team members find out which devices are connected to which system in an array of connected Linux machines.
That was all for now. In this tutorial we have different aspects of the Udev Program to see how we can manipulate our hardware in the best possible way. In future guides we will help you make complex changes to your hardware. We also performed operations with simple commands to find out all the hardware connected to your system.