HOW TO DISCOVER THE LARGEST FILES ON DISC

Ficheros Más Grandes
DISCOVER THE LARGEST FILES ON THE DISC

Sometimes we find that our main hard drive where we have installed Deepin Or maybe another of our disks is filling up fast. You may even begin to receive warnings from the operating system or other applications about the fact that there is almost no free space available on disk X. You are nevertheless sure that you have not downloaded large files or anything that may have filled the disk so suddenly.

This can happen for several factors, for example; Some program is generating a .log file (event log) that is too large due to some type of error or you have simply asked an application to perform scheduled tasks at a too fast pace and this task generates numerous files, For example you have asked to do tasks system backup at hourly intervals to take an example.

Whatever the cause, your disk is filling up and you need to identify the cause and above all, you need to find and delete those files that are filling up your disk.

In the following command, the prompt -l means long list and -to tells ls which lists all files including (.) or hidden files. To prevent files from being displayed . Y .., use the option -TO instead of -to.

To list all the files in a directory, open a terminal window and run the following command.

ls -la

Note that when the command ls es invocado sin ningún argumento, alistará los archivos en el directorio de trabajo actual. Así es que si simplemente abriste una terminal y escribiste el comando anterior entonces este alistara todos los ficheros en el directorio raíz de tu cuenta en el sistema.

To list all the files in a specific directory you can do it in the following way, for example to list all the files in my directory / var, I would use the following command:

ls -la /var/

The above would return the following result:

To list all files and sort them by size, use the option -S. By default, it displays the output in descending order (from largest to smallest).

ls -laS /var/

You can also get the file sizes in a human readable format by adding the option -h as it's shown in the following.

ls -laSh /var/

Or to get an even more detailed list of all files according to their size, starting with a minimum size of 1 MB until reaching the largest file at the end of the list, you can also execute the following command. (Also remember that if you do it from the root directory then it will list all the directories and files in it, so exercise caution.)

du --max-depth=1 | sort -n | awk 'BEGIN {OFMT = "%.0f"} {print $1/1024,"MB", $2}'

Once all the files and directories are listed, let's say that I want to know what is taking up so much space on my 120GB PNY external drive, then I would run the following commands to move to that directory and re-list all the files and directories under that path as follows:

cd /media/eli/PNY\ CS900\ 120GB/
sudo du --max-depth=1 | sort -n | awk 'BEGIN {OFMT = "%.0f"} {print $1/1024,"MB", $2}'

As you can see above, what is occupying the most space on my PNY disk is the directory of TimeShift (The directory where I keep my backups created with TimeShift) Note that in the command above it was necessary to use sudo, since that area is not fully accessible to the current user. Depending on which directory you want to check, it may be necessary to use sudo.

We hope the article will help you in the future. If you have any questions or suggestions or even alternative methods, don't forget to let us know and comment on it. It will surely help.

5 20 votes
Rate the Article
 
Subscribe
Report of
7 Reacciones
More popular
Newer Older
Opinion from the article
See all comments
Isaías Gätjens M
Isaías Gätjens M (@igatjens)
Admin
7 meses atrás

Most of the time I use the terminal to search the heaviest folders and files, but I also sometimes use graphical applications oriented to perform the same task, that of searching the heaviest folders and files.

The ones I like the most are:

  • k4dirstat
  • baobab
  • qdirstat
  • filelight

And their corresponding installation commands are

sudo apt install k4dirstat sudo apt install baobab sudo apt install qdirstat sudo apt install filelight

The advantage is that they visually show the size of folders and files.

Greetings.

Juan Carlos
Juan Carlos (@juan-carlos)
Member
7 meses atrás

Great Eli, you always learn something new around here.
Regards.

Luis Serrano
Luis Serrano (@luis-serrano)
Member
7 meses atrás

Incredible everything that can be done with the terminal in linux. I never back down hee hee

Vicente Blanco
Vicente Blanco (@vicente544blanco)
Member
7 meses atrás

Excellent contribution.

Ernesto Junco
Ernesto Junco (@ernesto_junco)
Member
7 meses atrás

Very good tutorials as usual.

Luis Linux
Luis Linux (@ddluislinuxfinal)
Member
7 meses atrás

Interesting, but also useful, thank you.

DarioAR
DarioAR (@darioar)
Member
7 meses atrás

Very interesting, thanks.

7
0
We would like to know what you think, join the discussion.x
()
x