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 LAMP trên CentOS 7

LAMP là một hệ thống các phần mềm để tạo dựng môi trường máy chủ web được viết bằng...
30/12/2020

[DNS] Hoạt động của hệ thống DNS

Ở bài viết trước bạn đã biết được chức năng của DNS và vai trò của nó trên Internet. Vậy...
30/12/2020

[Event Viewer][Log] Theo dõi và phân tích Log của Remote Desktop trên Windows

Remote Desktop Activity Log là Nhật ký hoạt động của các kết nối Remote Desktop, ghi lại những hoạt...
30/12/2020
Bài Viết

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

SỰ KHÁC BIỆT GIỮA RESIDENTIAL PROXY VÀ PROXY DATACENTER
17/02/2024

Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail
07/01/2024

Mua shadowsocks và hướng dẫn sữ dụng trên window
05/01/2024

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?
04/01/2024

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo
02/01/2024