du Command on Linux

29/12/2020
Every Linux distro comes up with a number of tools integrated into the system. Each of the tools has their own purposes. “du” is such a tool that’s part of the standard Unix/Linux. This tool is used for getting info on disk usage and directories on machines. There are a number of available parameters that you can use for getting results in many formats. Here are some of the most useful commands of “du”.

“du” examples

  • Need to find out the disk usage summary of a directory? Run the following command –
  • du ~/Downloads/

In the output, the first column is the disk usage amount and the second column is the list of files present in that directory.

The first column shows the number of disk blocks the corresponding file is occupying.

  • Need the output in a format that human can understand? Use the “-h” option. It tells the “du” to show output in “Human Readable Format”.
  • du -h ~/Downloads

  • Use “-a” flag for displaying the disk usage of all the files and directories.
  • du -a -h ~/Downloads/

As you’ve noticed, you can use multiple flags together with “du”.

  • For identifying just how much disk space is a directory consuming, use “-s” flag.
  • du -sh ~/Downloads

  • You can also use the “-c” flag for getting the total size of the directory at the last line of the output.
  • du -ch ~/Downloads/

  • Need to check out the last time of file modification? You have to use “–time” flag.
  • du -ha –time ~/Downloads/

  • Are you interested in excluding specific file types, for example, MP4 or PDF? Then use the “–exclude=PATTERN” parameter.
  • du -ha –exclude=*.svg ~/Downloads/

More “du” commands

“du” offers a huge collection of features. You can find out all of them using the man page for “du”.

man du

Every time you need help, you don’t have to open up a terminal and run the command again. You can dump the guide into a text file. Run the following command –

man du > ~/Desktop/du.txt

Enjoy!

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 stack trên Ubuntu 20.04 LTS

LAMP (viết tắt của Linux – Apache – Mysql database hoặc MariaDB – PHP.) là một hệ thống...
30/12/2020

Install TeamSpeak 3 Client 3.1.0 on Linux – Improved echo cancellation

TeamSpeak 3 is a secured voice enabled software that allows users to communicate between each other over the Internet or...
28/12/2020

How to install QupZilla 2.1.2 Lightweight Browser on Linux

QupZilla 2.1.2 recently released, is one of the new and very fast QtWebEngine browser released. The goal behind this browser...
28/12/2020
Bài Viết

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

Dịch Vụ Xây Dựng Hệ Thống Peering Với Internet Exchange (IXP)
04/04/2025

Dịch Vụ Triển Khai VPN Site-to-Site & Remote Access
04/04/2025

Dịch Vụ Thiết Lập Hệ Thống Tường Lửa (Firewall)
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ảo Hóa & Cloud
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ceph
04/04/2025