sysfs File System (Demo)
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 »

Video Transcription
00:00
>> Hey Cybrarians, welcome back to
00:00
the Linux Plus course here at Cybrary.
00:00
I'm your instructor Rob Goelz and in today's lesson,
00:00
we are going to be talking about the sysfs file system.
00:00
Upon completion of today's lesson,
00:00
you're going to be able to understand
00:00
the purpose of this sysfs file system.
00:00
We're going to explain the information that's
00:00
held in the sys directory and then we're
00:00
going to review the contents of
00:00
the sys directories to find information.
00:00
The sysfs file system is really
00:00
just another virtual directory or
00:00
pseudo file system similar to block,
00:00
and in this case,
00:00
the virtual directory is mounted at /sys,
00:00
and that's used to provide
00:00
>> user space with properties and
00:00
>> statistics from hardware devices and file systems.
00:00
Kernel modules detect any device on boot and it creates
00:00
a subdirectory in that sys
00:00
virtual directory or pseudo file system,
00:00
and that just contains the device information.
00:00
Sys has a lot of directories,
00:00
but an abridged listing here
00:00
would be things like /sys/block,
00:00
which is going to contain information on block devices,
00:00
/sys/bus is going to contain
00:00
any statistics about system buses,
00:00
as well as entries and drivers for
00:00
devices that are found on the bus.
00:00
The /sys/devices directory holds
00:00
a hierarchical device presentation,
00:00
so the actual devices that we find in
00:00
/sys/bus devices are going
00:00
to be semi-linked into /sys/devices.
00:00
/sys/fs is where you find information about
00:00
mounted filesystems or devices
00:00
that are using file systems,
00:00
and then finally, /sys/kernel
00:00
holds kernel status information.
00:00
Let's look closer at this with some demo time.
00:00
Here we are back in Ubuntu,
00:00
and let's first of all just get
00:00
a basic directory listing of sys.
00:00
In here what we can do is we can see
00:00
a bunch of different information like I said,
00:00
we can see information about block, bus,
00:00
devices, fs, and kernel.
00:00
Let's take a look at the bus directory first.
00:00
Let's do an ls on /sys/bus.
00:00
Inside of here we can see all of
00:00
the different devices that exist on the system.
00:00
Let's just pick one to take a look at.
00:00
Let's look at the folder
00:00
for the discovery bus so we could do
00:00
an ls-al
00:00
on /sys/bus/scst.
00:00
Then we can also see that there's a folder
00:00
for devices and drivers on this scst bus.
00:00
Let's look at the devices folder.
00:00
We'll do an ls-al on sys/bus/scst/devices,
00:00
and there we go.
00:00
We see that these are actually
00:00
all siblings to the devices folder.
00:00
This.. /../../ Tells us
00:00
that it's going up three directories two devices.
00:00
If we just go up 1, 2,
00:00
3, this is where these are actually all stored.
00:00
We can see in here
00:00
the devices and they'll be pointed to different PCI.
00:00
So we see PCI 000,
00:00
0000. Here we go right here.
00:00
If we do an ls-al on that,
00:00
we can see all those scst devices.
00:00
Likewise, if we do an ls-al on,
00:00
let's say /sys/block/sda,
00:00
we can see that this is also
00:00
similarly back into devices directory.
00:00
It's semi-linked into the PCI yada yada yada,
00:00
which is how this is
00:00
the actual bus that the drive is using.
00:00
Really, since it's
00:00
just a way for the kernel to organize data,
00:00
statistics and properties on devices,
00:00
and then other applications can make use
00:00
of this data in the Linux operating system.
00:00
But with that, we've reached the end of this lesson.
00:00
In this lesson we covered
00:00
the purpose of the sys file system,
00:00
we talked about the information that's
00:00
held in the sys file system,
00:00
and then we got to take a look at the content
00:00
of some of the sys directories.
00:00
Thanks so much for being here and I look
00:00
forward to seeing you in the next lesson.
Up Next
Instructed By
Similar Content