Disk Space Commands (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 »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hello, Cybrarians.
00:00
>> Welcome back to the Linux+ 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
discussing Disk Space Commands.
00:00
Upon completion of lesson you're
00:00
going to be able to use the commands
00:00
du and df to look at this space.
00:00
In the previous lesson,
00:00
we spoke about the FHS,
00:00
the file system hierarchy
00:00
standard in real and virtual file systems.
00:00
But that begs the question,
00:00
how do we see the disk space using this file systems?
00:00
What say we answer that question with some demo time.
00:00
Here we are over in our demo environment and
00:00
the first command we're going to play
00:00
with is the df command.
00:00
Now the df command is used to display displace
00:00
information on the mounted file systems in Linux.
00:00
If we just type in df it will display
00:00
the information about that.
00:00
But what we can see is this is pretty unreadable.
00:00
Let's try df -h,
00:00
and that's much better.
00:00
That is called the human-readable option.
00:00
The dash H flag is the human readable option.
00:00
What that does is it displays
00:00
the size of the files rather than the one K blocks,
00:00
which is a little bit easier to understand
00:00
and obviously we still see the file systems,
00:00
the amount used and available,
00:00
the percentage used and where
00:00
this file system is mounted.
00:00
Now we can run a couple of other options here.
00:00
For example, we can run df -T,
00:00
and that will get back the information
00:00
about the number of blocks that are used,
00:00
the one K blocks that are used.
00:00
Or if you want to run df -A is going to give us
00:00
all of the information about the system,
00:00
and it's going to give us not only
00:00
the file systems that are real,
00:00
but the virtual file systems as well on this system.
00:00
Let's go ahead and just type in
00:00
clear or hit Control L to clear the screen,
00:00
give us back a little bit more screen
00:00
real estate to see what we're doing.
00:00
Now the next command we're going to work
00:00
on is the du command.
00:00
Du command is used to get information about the amount of
00:00
space used in all files in a particular directory.
00:00
Let's just run this, that is a lot of garden.
00:00
That's a whole bunch of output.
00:00
By itself again, it's pretty unreadable.
00:00
Let's see if we could do the same trick
00:00
and use the H option,
00:00
the human-readable option,
00:00
and that's much better.
00:00
Now on our left-hand side, our left column,
00:00
we actually see things in file size,
00:00
and that is much preferable to seeing them in block size.
00:00
Couple of other things we could do.
00:00
We could do du -C if we wanted to just
00:00
see the total size
00:00
from the entire directory at the bottom,
00:00
such as total there and we can do
00:00
du CH that's human-readable as well.
00:00
Then we can also du -SH.
00:00
Let's clear our screen here.
00:00
Let's just hit Control C and then type
00:00
Control L to get a clear screening in,
00:00
and we're going to do du -SH.
00:00
What that gives us is just the very summary,
00:00
the last line, the total of all of
00:00
the content in human-readable format.
00:00
If you find yourself having to look through
00:00
a directory and figure out if it's full,
00:00
you can just do du -SH to see what's
00:00
going on with the directory and how much space
00:00
is being taken up in it.
00:00
But then we've reached the end of the lesson.
00:00
In this lesson we covered the df and du commands.
00:00
Thank you so much for being here,
00:00
and I look to seeing you in our next lesson.
Up Next