Table of Contents
Why do I need to free up disk space?
How to find out what is taking up disk space on Linux:
To find out the size of files and directories, you can use the du (short disk usage) command.
Write du -sh * and the output will look like this:
What do the -sh * keys mean:
-s – displays the size only for the folder passed as an argument, not for each file in that folder.
-h – displays the sizes in a human-readable form (2K, 18M, 4G)
* – selects all objects in the current directory for counting.
To take a closer look at a folder, use the following syntax to navigate deeper into the folder:
du / path_to_directory
For example, du -ah/var / log
-a – displays the size for all files, not just directories.
This method may not seem convenient enough, so we will look at the second option.
Using the ncdu command (NCurse Disk Usage)
You can install ncdu through the terminal with the «sudo apt-get install ncdu» command.
Enter the command and wait for it to calculate the used space.
The results will be displayed as a list with the relative path and size of each object.
The ncdu command has a pseudographic interface, that is why it will be easier and more convenient to use it.
The arrow keys are used to navigate. Use the up and down keys to select an item, and use the left and right keys or the Enter key to enter the selected categories.
Another distinguishing feature of the ncdu command is the hotkeys that are used for control.
Some of them are presented below:
a – switching to the mode of displaying the actual used disk space in bytes
q and b – exit the program to the console
d – delete the selected object
e – show only hidden files
g – switch to the mode of displaying the used place as a percentage
i – display information about a file or folder
k and j – same as up-down keys
n and s – sort by name and size
r – recalculation of used space
Unfortunately, both methods do not have a convenient graphical interface, and therefore it is not so easy to work with them in order to find out what is taking up disk space.
There are many third-party utilities that have a great interface and advanced functionality. With them, you can easily and visually be able to find out what is taking up disk space on your computer.