I am using AWS Free tier Ubuntu. It is saying that disk space full in /dev/xvda1 which is mounted on / . I am using df command to check it.

I went to the directory / and using command ls -l to check which file is taking much space. But, none of them is taking that much within / . What is the recommended way to find out which file is taking much space ?

I have attached the screenshot, please check it. You can see none of them is taking 99892768 space.

enter image description here

  • 1
    The size of the files, as displayed by ls, is only the size of the file itself: if the file is a directory, this will not include the size of the directory contents. – joH1 Jan 3 '18 at 11:50
  • Please don't post screenshots of text. Copy and paste the text itself and format it as code with the {} icon in the editor. – cas Jan 3 '18 at 12:01
  • You may want to remove old kernel images with sudo apt autoremove, usually this solves a problem like yours. – dessert Jan 3 '18 at 12:02

To find find the largest files and directories that exist on your system, you can run:

du / | sort -n

The largest files and directories will be printed at the end. Use tail to find the nth largest:

du / | sort -n | tail -n 20

This will print the 20 largest files and directories on the system.

| improve this answer | |

ls does not show disk use for directories. As you can see all directories are shown as 4096B, which is clearly incorrect.

I suggest that you install ncdu by running sudo apt-get install ncdu, and then run sudo ncdu /.

This will show you the current disk use for the various directories, sorted by size.

| improve this answer | |
  • 2
    No space left to even install this – codeclue Jan 3 '18 at 11:55
  • Then go with du -sh /*, which is already installed. – vidarlo Jan 3 '18 at 11:56

ls -l does not provide full information about disk-space usage for directories. As you can see, all directories (per directory) have constant size, it means 4096. If you want to see sum of directory usage, type:

du -sh /*

du is kind of tool that shows disk usage per file. -s means summarize and -h means make output human readable.

If you want to find largest file at /var/ directory by example, I would try with that:

du -a /var | sort -n -r | head -n 10


| improve this answer | |
  • @dessert Yes, of course. Edited. Thank you very much. – user263770 Jan 3 '18 at 11:55
  • it is saying /var is taking much space. Now, how to find which file within /var ? – codeclue Jan 3 '18 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.