{"id":127546,"date":"2020-12-29T01:22:02","date_gmt":"2020-12-29T01:22:02","guid":{"rendered":"https:\/\/onet.com.vn\/check-disk-space-usage-on-centos.html"},"modified":"2020-12-29T01:22:02","modified_gmt":"2020-12-29T01:22:02","slug":"check-disk-space-usage-on-centos","status":"publish","type":"post","link":"https:\/\/onet.com.vn\/check-disk-space-usage-on-centos\/","title":{"rendered":"Check Disk Space Usage on CentOS"},"content":{"rendered":"\n
Users need to know the used and available size of disk space.\u00a0 There are many built-in tools and commands for Linux based operating system to do these type of tasks.\u00a0 How you can check and monitor the disk usages on CentOS operating system is shown in this tutorial.<\/p>\n
\t\t\t \t\t \t\t \t\t \t\t \t<\/div>\n

Check disk space and usage<\/strong><\/h1>\n

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

df command:<\/strong><\/h2>\n

df<\/strong> command is used to get the details disk spaces information of the file system. Here, df<\/strong> stands for d<\/strong>isk f<\/strong>ilesystem. 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.<\/p>\n

\n
$ <\/span>df<\/span> –help<\/span><\/div>\n<\/div>\n

–help is the common option for any command to get all information for using the command. Before using df<\/strong> command you can run df<\/strong> command with –help<\/strong> option to get detail information about the use of this command.<\/p>\n

<\/p>\n

\n
$ <\/span>df<\/span> -h<\/span><\/div>\n<\/div>\n

-h<\/strong> option is used with df <\/strong>command to display the disk space in human readable format. Disk space value will be shown in GB<\/strong> and MB<\/strong>.<\/p>\n

<\/p>\n

\n
$ <\/span>df<\/span> -m<\/span><\/div>\n<\/div>\n

-m <\/strong>option is used with df <\/strong>command to show the disk space in MB.<\/p>\n

<\/p>\n

\n
$ <\/span>df<\/span>\u00a0 -T<\/span><\/div>\n<\/div>\n

-T <\/strong>option is used with df <\/strong>command to show the file type.<\/p>\n

<\/p>\n

\n
$ <\/span>df<\/span> -h<\/span> Public<\/div>\n<\/div>\n

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<\/strong> folder.<\/p>\n

<\/p>\n

\n
$ <\/span>df<\/span> -hT<\/span><\/div>\n<\/div>\n

You can use two options -hT<\/strong> together to get the file types in human readable format.<\/p>\n

<\/p>\n

du command:<\/strong><\/h3>\n

Another useful command to find out the usage information is all files and folders. Here, du stands for d<\/strong>isk u<\/strong>sage. 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.<\/p>\n

\n
$ <\/span>du<\/span> \u2013help<\/span><\/div>\n<\/div>\n

The output will show all options to use du<\/strong> command.<\/p>\n

<\/p>\n

\n
$ <\/span>du<\/span> -h<\/span><\/div>\n<\/div>\n

The output will show the size information of files and folders in more human readable format.<\/p>\n

<\/p>\n

\n
$ <\/span>du<\/span> -h<\/span> Downloads<\/div>\n<\/div>\n

The output will show the size of Downloads <\/strong>folder.<\/p>\n

<\/p>\n

\n
$ <\/span>du<\/span> -h<\/span> –time<\/span> Downloads<\/div>\n<\/div>\n

The output will show the size of Downloads folder with last modification time.<\/p>\n

<\/p>\n

\n
$ <\/span>du<\/span> -m<\/span> Downloads<\/div>\n<\/div>\n

The output will show the size of Downloads<\/strong> folder in MB<\/strong>.<\/p>\n

<\/p>\n

free command:<\/strong><\/h3>\n

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

\n
$ <\/span>free<\/span><\/div>\n<\/div>\n

The output shows the memory and swap usage information in byes.<\/p>\n

<\/p>\n

\n
$ <\/span>free<\/span> -h<\/span><\/div>\n<\/div>\n

The output shows the memory and swap usage information in GB and MB.<\/p>\n

<\/p>\n

\n
$ <\/span>free<\/span> -m<\/span><\/div>\n<\/div>\n

The output shows the memory and swap usage information in MB.<\/p>\n

<\/p>\n

Monitoring disks: <\/strong><\/h3>\n

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.<\/p>\n

\n
$ <\/span>fdisk<\/span> –help<\/span><\/div>\n<\/div>\n

Run the above command to know the detail information of fdisk<\/strong> command for using it.<\/p>\n

<\/p>\n

\n
$ <\/span>sudo<\/span> fdisk<\/span> -l<\/span><\/div>\n<\/div>\n

-l<\/strong> option is used to get information about all available partitions on your operating system. You have to provide root password to run this command.<\/p>\n

<\/p>\n

\n
$ <\/span>sudo<\/span> fdisk<\/span> -l<\/span> \/<\/span>dev\/<\/span>sda1<\/div>\n<\/div>\n

You have to mention the device name with \u2013l and fdisk command for getting the information of specific partition or device.<\/p>\n

<\/p>\n

\n
$ <\/span>sudo<\/span> fdisk<\/span> \/<\/span>dev\/<\/span>sda1<\/div>\n<\/div>\n

You can print the output of any device by executing fdisk<\/strong> 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 \u2018p\u2019<\/strong> to print the output.<\/p>\n

<\/p>\n

Conclusion:<\/strong><\/h4>\n

The basic uses of df, du, free<\/strong> and fdisk<\/strong> 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: <\/div>\n","protected":false},"excerpt":{"rendered":"

Users need to know the used and available size of disk space.\u00a0 There are many built-in tools and commands for Linux based operating system to do these type of tasks.\u00a0 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 […]<\/p>\n","protected":false},"author":1,"featured_media":127547,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"_links":{"self":[{"href":"https:\/\/onet.com.vn\/wp-json\/wp\/v2\/posts\/127546"}],"collection":[{"href":"https:\/\/onet.com.vn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/onet.com.vn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/onet.com.vn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/onet.com.vn\/wp-json\/wp\/v2\/comments?post=127546"}],"version-history":[{"count":0,"href":"https:\/\/onet.com.vn\/wp-json\/wp\/v2\/posts\/127546\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/onet.com.vn\/wp-json\/wp\/v2\/media\/127547"}],"wp:attachment":[{"href":"https:\/\/onet.com.vn\/wp-json\/wp\/v2\/media?parent=127546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/onet.com.vn\/wp-json\/wp\/v2\/categories?post=127546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/onet.com.vn\/wp-json\/wp\/v2\/tags?post=127546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}