Check Disk Space Usage on CentOS

29/12/2020
Users need to know the used and available size of disk space.  There are many built-in tools and commands for Linux based operating system to do these type of tasks.  How you can check and monitor the disk usages on CentOS operating system is shown in this tutorial.

Check disk space and usage

Most commonly used commands for checking disk spaces or usage or free spaces are df, du and free. The use of these commands with various options are shown in this section.

df command:

df command is used to get the details disk spaces information of the file system. Here, df stands for disk filesystem. Many options can be used with this command to check the disk space related information in different ways. The function of some options are explained below using examples.

$ df –help

–help is the common option for any command to get all information for using the command. Before using df command you can run df command with –help option to get detail information about the use of this command.

$ df -h

-h option is used with df command to display the disk space in human readable format. Disk space value will be shown in GB and MB.

$ df -m

-m option is used with df command to show the disk space in MB.

$ df  -T

-T option is used with df command to show the file type.

$ df -h Public

You can show the disk space information of any particular folder in human readable format by using above command. The output will show the disk space information of Public folder.

$ df -hT

You can use two options -hT together to get the file types in human readable format.

du command:

Another useful command to find out the usage information is all files and folders. Here, du stands for disk usage. This command retrieves information of folders and sub-folders and files recursively. So, this command can be used to get more detail information of disk usage. The options mentioned for df command is also applicable for du command, but the output will be different.

$ duhelp

The output will show all options to use du command.

$ du -h

The output will show the size information of files and folders in more human readable format.

$ du -h Downloads

The output will show the size of Downloads folder.

$ du -h –time Downloads

The output will show the size of Downloads folder with last modification time.

$ du -m Downloads

The output will show the size of Downloads folder in MB.

free command:

free command is used to get the detail used and unused information of the computer memory and swap.   You can also apply –help, -h and -m option with free command like previous commands.

$ free

The output shows the memory and swap usage information in byes.

$ free -h

The output shows the memory and swap usage information in GB and MB.

$ free -m

The output shows the memory and swap usage information in MB.

Monitoring disks:

Many tools are available in Linux operating system to monitor the disk. Some of them are built-in and some tool you will need to download and install before use. One of the mostly used built-in tool to monitor the partition of the disk is fdisk. Using this tool you can not only monitor the disk partition but also create, move, copy and delete disk partitions. You must have root privilege to run this command. How you can use this command on CentOS operating system are shown using various examples in this section.

$ fdisk –help

Run the above command to know the detail information of fdisk command for using it.

$ sudo fdisk -l

-l option is used to get information about all available partitions on your operating system. You have to provide root password to run this command.

$ sudo fdisk -l /dev/sda1

You have to mention the device name with –l and fdisk command for getting the information of specific partition or device.

$ sudo fdisk /dev/sda1

You can print the output of any device by executing fdisk command with device name. When you will run the command, a prompt will appear to take the next command if the device name exists. Type ‘p’ to print the output.

Conclusion:

The basic uses of df, du, free and fdisk command are shown in this tutorial. Many other fdisk commands are available to modify the disk partitions like creating new partition, deleting existing partition etc. For a video on this topic see below:

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Hướng dẫn cài đặt Wireguard trên CentOS 7

Tổng quan WireGuard là giải pháp VPN miễn phí, mã nguồn mở được phát triển nhằm thấy thế giải...
30/12/2020

[CI/CD] Phần 3: Hướng dẫn tích hợp Jenkins và Gitlab

Chắc hẳn các bạn đã nghe tới 2 khái niệm CI và CD và muốn tự động hóa một phần hoặc hoàn...
30/12/2020

How To Open Port 80 on CentOS7

If you’re planning to host websites on CentOS 7, then you might install a web server software such as Apache or Nginx....
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

mua Proxy riêng ở đâu, và nó đem lại lợi ích gì cho người sử dụng
22/11/2022

Hướng dẫn sử dụng Proxy Helper Fakeip khi thuê proxy
21/11/2022

PROXY NUÔI TÀI KHOẢN FACEBOOK – KINH NGHIỆM FAKE IP – THUÊ PROXY GIÁ RẺ
14/11/2022

Mua Proxy Nuôi Zalo Giá Rẻ Tại Onet.com.vn
14/11/2022

BẢNG GIÁ MUA PROXY VIỆT NAM và PROXY US Onet.com.vn
14/11/2022