1

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

3
  • 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. Commented Jan 3, 2018 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. Commented Jan 3, 2018 at 12:01
  • You may want to remove old kernel images with sudo apt autoremove, usually this solves a problem like yours. Commented Jan 3, 2018 at 12:02

3 Answers 3

2

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.

2
  • 2
    No space left to even install this Commented Jan 3, 2018 at 11:55
  • Then go with du -sh /*, which is already installed. Commented Jan 3, 2018 at 11:56
1

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.

1

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 

References:

2
  • @dessert Yes, of course. Edited. Thank you very much. Commented Jan 3, 2018 at 11:55
  • it is saying /var is taking much space. Now, how to find which file within /var ? Commented Jan 3, 2018 at 11:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.