Udevadm Commands

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hey, Cybrarian, welcome back
00:00
>> to the Linux plus course here at Cybrary.
00:00
>> I'm your instructor, Rob Goelz.
00:00
In today's lesson, we're going to be
00:00
covering the udevadm command.
00:00
Upon completion of this lesson,
00:00
you are going to be able to understand this command,
00:00
the udevadm command,
00:00
you'll be able to explain when we
00:00
might want to use this command,
00:00
and recall the common options for udevadm.
00:00
The udevadm utility is used to manage or gather
00:00
device information and it allows
00:00
you to send commands to udev.
00:00
What are some examples of
00:00
when you might want to use this command?
00:00
Well, you might want to use udevadm
00:00
to obtain information about a device.
00:00
Maybe you want to uevents that are
00:00
coming into the kernel or from the kernel.
00:00
You might want to control the
00:00
udevd daemon itself, udevd.
00:00
Or you might want to test changes that you're making to
00:00
rules before you reload them
00:00
>> and put them on the system.
00:00
>> Or once that's all good,
00:00
you might want to go ahead
00:00
>> and apply those rule changes.
00:00
>> Those are all things you can do with udevadm.
00:00
Here are some actual examples.
00:00
If you're trying to get information
00:00
about a device from the udev database,
00:00
you could use udevadm info -q for query,
00:00
and then you can specify a query type.
00:00
Name, symlink, path, property, or all.
00:00
If you want to perform real-time monitoring of
00:00
the udev events or uevents that come in.
00:00
you could do a udevadm monitor.
00:00
If you want to test a change to
00:00
a rule before you reload the role in the system,
00:00
you can run udevadm test
00:00
and then you specify the action,
00:00
so --add for example,
00:00
in the device file that you want to test.
00:00
If you want to reload those rules
00:00
once you verify that that
00:00
change is good and basically is control udevd,
00:00
you could do a udevadm control --reload,
00:00
and that will reload those rules it's the udevd daemon.
00:00
Then to verify the rule
00:00
after the device has been created,
00:00
you can run udevadm trigger.
00:00
Let's take a look at some of these inaction
00:00
with some demo time.
00:00
Here, we are back in our Bundoo environment.
00:00
Let's play with udevadm command.
00:00
The first thing we could do is
00:00
display some device options.
00:00
We can do that with udevadm info -n, n is for name.
00:00
We'll just pick on dev sda,
00:00
which is one of our storage devices.
00:00
Then we can see a bunch of
00:00
good information about its path,
00:00
and its name, and so on, and so forth.
00:00
If we wanted to get
00:00
properties related to this device only,
00:00
we could run udevadm info q
00:00
for query and we're going to query on
00:00
the property of this device.
00:00
In property, we're going to use the name,
00:00
dev sda is the device we want to get information on.
00:00
Then hit Enter, and there we go.
00:00
We have information property
00:00
just specific to this device.
00:00
Now if we want to perform real-time monitoring of udev,
00:00
let's clear our screen by hitting
00:00
Control L or typing clear.
00:00
To do this, we can run the command udevadm monitor
00:00
and this will just print
00:00
any received events for udevadm,
00:00
the uevents that come in or
00:00
any kernel uevents that are being sent.
00:00
Nothing really going on in
00:00
the system so we're not going to see anything here,
00:00
but that's how we can monitor them in real-time,
00:00
the equivalent of a tail f but for udevadm.
00:00
Then if we had a rule change, we could test it.
00:00
Now I don't really actually have
00:00
any rural changes to test,
00:00
but I have an existing device we can play around with.
00:00
What I'll do is I'll do a udevadm test --action
00:00
and our action in this case is going to be add.
00:00
We'll mess with a character device dev char 890.
00:00
If we liked the way
00:00
this worked, if we were happy with it,
00:00
if we're satisfied with it,
00:00
we can reload the udevadm rules.
00:00
We can say pseudo,
00:00
udevadm control --reload,
00:00
and that will reload the
00:00
udevadm rules and pick up the changes.
00:00
But with that, we reached the end of the lesson.
00:00
In this lesson, we covered
00:00
the purpose of the udevadm command.
00:00
We talked about when you might want to use
00:00
the udevadm command and some of
00:00
the common udevadm options.
00:00
Thanks so much for being here and I look
00:00
forward to seeing you in the next lesson.
Up Next