InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Ubuntu tutorials

  • How to add a user on Linux with sudo access
  • How to check if a user has password on Linux
  • How to install ViewVC for svn repository on Ubuntu Linux
  • How to setup ssl (https) for your site on Ubuntu Linux
  • Install rabbitmq on Ubuntu Linux
  • LXC (Linux Containers) - quick start tutorial on Ubuntu
  • Linux - command to check swap size
  • Linux - how to add a user using useradd
  • Linux - how to create a large file like 1GB
  • Linux - how to create swap partition
  • Linux - how to remove user from a group
  • Linux - number of cpus (lscpu)
  • Linux du - find disk usage of directories or files
  • NFS client and server handy commands
  • Setup svn repository on AWS Ubuntu with apache auth
  • Ubuntu - check if a service is upstart based
  • Ubuntu - dpkg and apt-get beginner tutorial
  • Ubuntu - find file to package
  • Ubuntu - find where will a package be installed from
  • Ubuntu - how to auto start services on boot using update-rc.d (sysv init)
  • Ubuntu - how to find boot autostart status of a service
  • Ubuntu - reload iptables rules during boot
  • Use x2go to access remote Ubuntu Linux
 
  • Home
  • > Tutorials
  • > Linux

Linux du – find disk usage of directories or files

on Apr 18, 2016

Linux du command can be used to find disk usage of files and directories. Here are some handy du commands on Ubuntu Linux (or any other Linux).

Find disk usage in block size

Find disk usage of file or directory (in –block-size, default is 1K usually). It is usually larger that actual file size.

$ du 10K_file1.out 
12

disk usage in human readable format

$ du -h 10K_file1.out 
12K	10K_file1.out

Find apparent disk usage

Print apparent sizes, rather than disk usage. The apparent size is usually smaller, but it may be larger due to holes in sparse files.

Smaller apparent size case:

$ du --apparent-size -h 10K_file1.out
10K	10K_file1.out
Larger apparent size case:
$ truncate --size 1M 1M_file_created_using_truncate.out
$ du -h 1M_file_created_using_truncate.out
0	1M_file_created_using_truncate.out
$ du --apparent-size -h 1M_file_created_using_truncate.out
1.0M	1M_file_created_using_truncate.out

Display count for all files

To display count of all files (inside directories):

$ du --all dir1
0	dir1/large
10240	dir1/file2.out
10244	dir1

Suggested posts:

  1. Jenkins how to clone a project
  2. Javascript onscroll event handler with throttling
  3. minikube kubernetes – create deployment with multiple replica and load balancer
  4. Mac Finder – how to search system hidden files
  5. Mysql – how to copy a table
  6. HTML – is closing li tag required?
  7. Gmail – how to find large size emails
  8. How to install drupal on Mac usin MAMP
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Linux, Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress