Categories: Linux

How to detect and manage devices on Linux

Many of the Linux beginners coming from Windows know how to manage devices on their Windows systems. But they do not know how to do the same on Linux unfortunately. This is not because Linux is different, rather they are new and unaware of where to find the right help. Here I am going to help you how to detect and manage devices in your Linux system. I will be using Ubuntu 20.04 distribution. All commands are valid for related distribution which uses the apt package manager.

What is Udev?

We use Udev as our device manager for the Linux kernel. It helps with creating and removing device nodes in the /dev directory. It is Udev that enables the plugging of USB devices and network disks. It helps a system admin to manage devices connected to a Linux system.

We apply rules in /etc/udev/rules.d/ directory, and Udev processes the changes once a device is connected.

I will use the udevadm tool to interact with the Udev device manager. Let’s do it.

How to detect a disk?

Using the following command you will be able to see a lot of data regarding a particular device. Usually, disks start with /dev/sda or /dev/sdb so we will also use the same format to detect our disk too.

$ udevadm info /dev/sda2

You’ll see an output like below:

This gives us a lot of information. You can see that it shows us each and every bit of the information available related to our disk. In the last lines of the terminal, if you take notice then you will find that it shows a disk running under VBOX. It also shows the related UUID of the disk.

Using Udev, you can also change the name of your disk, USB devices, and network cards.

For instance: If you go to the rules list, you will find out that there are a number of devices available to update their names.

Here is a demo of the rules list file. Type the following command and check your rules file.

$ cd /etc/udev/rules.d/

I am using a nano text editor on my Ubuntu server, therefore I will use the following command to open up the rules file.

It is important to remember that Udevadm info starts with the device specified by the devpath and then takes us to the chain of parent devices.

The file shows each and every device available. It can be disabled, removed, and renamed.

Why rename a device?

When it comes to team management, it is better to rename a device. This helps your team members to figure out which devices are connected to which system in an array of connected Linux machines.

Conclusion

This was all for now. In this tutorial, we discussed different aspects of the Udev program to see how we can manipulate our hardware in the best way possible. In future guides, We will help you with how to make complex changes to your hardware. We also ran operations using simple commands to find out all connected hardware with your system.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago