Oh yes, our first demonstration. And I'll just say,
we'll be working in this demonstration on Alma Linux 8.5. Later on in this
module, we'll also see some demonstrations on openSUSE. But we're going to begin
by discovering our hardware, looking at block devices,
among other things,
checking available disk space, and going through and seeing some of the
extra options that we're going to be able to find with ls if we truly dig
down and look. And here we are on our Alma 8 system.
If I go through and just take a look, we know we've got the ls command.
Ls is for listing, but we can also go through and list our
block devices, so lsblk, as we can see lists our block
devices. In this case, we've got one disk.
The disk name is device sda, sd for SCSI disk. However,
don't get too bogged down with that.
Pretty much, most disks in Linux these days will be run by the
SCSI disk driver, and that includes USB drives.
SCSI drives, IDE drives,
SATA drives. Many are going to show as sda, sda just
indicating it's the first disk. And then we've got two
partitions, one's being used for virtual memory,
so SWAP space, and one's being used as the root filesystem.
We can see the mount point showing SWAP and forward slash for root. And
we started off with the ls command, and then we said,
well, look, lsblk. And the reason why I did that is that we can also use the
ls command to go through and list other things. I need elevated privileges,
but I can go through and take a look at lspci. And this will then show me my
PCI bus, and we can see that we've got things such as our Ethernet controller.
We've got an IDE interface.
So even though when we take a look at our disk,
it uses the sd, the SCSI device driver. We can see, actually, we've
got IDE drives and a SATA controller plugged into this. Using my
normal control and l, I can clear my screen.
Lscpu is going to show me, then my CPUs. This will be a quick way
to work out how many CPUs I've got in my system.
If I just scroll up slightly,
we can then go through and see we've got one CPU, and when
we go through and take a look at this,
we've got then one core per CPU. If I run lsusb, we'll be looking at
the USB bus. On this system, we don't have a USB bus, so we don't
have the lsusb command, but it's well worth looking at some of these
additional listing commands.
So even though we are particularly interested in listing our block devices,
we can list other devices.
Our block devices though, if I do a long listing of /dev/, and when we go
through and take a look at it, we're going to use, then sd*. So we can go
through and see all of the device files that start sd.
And we can see then, again, we see sda, sda1, and sda2. When we look
at the file type, they're marked as block devices.
But when we go through and take a look at what would
normally be the size of the file,
we see the major device driver, so that's then 8, representing
our SCSI disk driver, and then the minor number is really
looking at the index on that device.
And again, if I go through and run my lsblk command, we can see
the major and minor number and where it relates to when we look at
our block devices in the filesystem.
If I want to check the available disk space that I have on my root filesystem,
I can go through and use the df command.
Typically, we're going to want it is human readable because most of us
are probably humans. And when we go through, we can go through, then
and put our root filesystem, and we can see here that it's 18 GB in
this virtual machine, and we've only got 1.7 GBs in use, giving me
roughly 16 GB available.
So a lot of great information as to how much space you've got
available and what planning do we need to do if any for migrating
files onto other filesystems? We can also go through and use the
du, the disk usage command.
I can use this against an individual file.
So if I go through and take a look at, let's say, /etc/services. So we can just
check the file size, rather than any of the other metadata.
But often, we use it when I want to look at the size of a directory.
So if I go through and take a look at the etc directory and then
just show a summary, again, I don't have access to the complete
directory structure, so I get a few errors showing up, but we can
see there the 23 MG as our summary.
If I didn't put the summary, we would get a listing of every single file in that
etc directory, so the summary is really good to use. Now another really cool
thing that we can use with our ls command, and yes,
believe me,
there are some really cool things, if I go through and say do an ls
‑lh /etc, we can see, then that we have got that file size that shows
kind of in the middle of our listing.
But especially, if we're looking at trying to migrate some files,
based it on the size of the file might be a good idea.
So if we go through and use the uppercase S to sort on the file
size, and a reverse listing is going to list,
then the largest files last.
That means they're going to be at the bottom of my listing, and
we can see the largest file that we have within the etc
directory is the services file at 677 K.
And look, way larger than the next one, which is 13 K.
But really, really useful tools.
Just have to dig and take a look a little bit at the extra options,
the help and the man pages that's going to give us the information we need. Go on, read the documentation.