How to check which file is consuming more space in linux

How to check which file is consuming more space in linux.Linux is an operating system that increases the number of users day by day, thanks to its stability, speed and cost (totally free), being free software , it allows to manage the processes it executes more extensively. For example, check and control the directories, since these, by consuming a lot of hard disk space, affect the general performance of your PC, if you are wondering what files have monopolized the memory of the computer?   How much space do they take up? Keep reading and we will explain below.

How to check which file is consuming more space in linux

 

Index

  1.  How can you use the du command to see the largest folders?
  2.  What is the way to use the find command on a Linux path?
  3.  What steps do you have to follow to see your largest files in Linux with the find command?
  4.  How to compress the space that a folder occupies in Linux?
    1.  What to do to see the available space on your Linux PC?
    2.  How else can you free up memory?

How can you use the du command to see the largest folders?

The DU command is an abbreviation for “Disk Usage” so it obviously refers to the use of your computer’s disk, its objective is to quantify the occupation of a certain directory or file on your hard disk. To achieve this you must do the following:

  1. Open a terminal, to do this simultaneously press the “Ctrl + Alt + T” keys.
  2. Enter the command with the following structure “ du -a /DirectoryName | sort -n -r | head -n 7 ”, remember to replace the “DirectoryName” section with the name of the folder, in which you are looking for the most important directory.
  3. If, instead, you want to search the entire system for the heavier directories, the code you should run is this “du -a | sort -n -r | head -n 7” or “du -hs * | sort -rh | head -7”, to do the search in subdirectories alike.

The system will return a list, with the main directories, according to their consumption of space on the hard disk, it is interpreted as follows, The first column refers to the size of the file on the hard disk (with the last code, expressed in units storage), then the path or name of each one, another consideration is that as many directory lines as the last number of the statement will be displayed, it is an example of 7. Remember the directory with the greatest weight, it is the one displayed first in the list.

What is the way to use the find command on a Linux path?

Linux Find is a very useful command that fulfills the function of finding files and directories, under hierarchy criteria and optimizing resources. The way it manages to check your system is through a strict syntax that consists of a hyphen (-) followed by the parameter/filter to apply (name, type, owner, size, etc.), a space ( ) and value of the chosen parameter.

Find is a command that returns information, about the size of the files, to use it you must use the command terminal . The correct way to use it in a route is:

  • find . <SearchParameter>”, to search in the current folder.
  • “find ~ <SearchParameter>”, to search within the current user’s folder.

 

What steps do you have to follow to see your largest files in Linux with the find command?

Follow this structure to know exactly which files have the most weight in your Linux operating system ; In a terminal run “ find -type f -exec du -Sh {} + | sort -rh | head -n 7”, as with the previous command, the last number determines the number of results you will see, in this case you will see the 7 largest directories.

Automatically, the first figure is shown with unit of measure, because it represents the size in ascending order, you will see the names of each one. In another case, if you need to search within a specific path , the command must be modified to “find /PathDeldirectory -type f -exec du -Sh {} + | sort -rh | head -n 7”, remember to replace the path with the required one.

How to compress the space that a folder occupies in Linux?

When determining which folder or file on your PC is the one that takes up the most space, you are probably wondering what you can do, if so, try compressing the folder in question so that it takes up less space. Compressing a folder in Linux is a simple task, which converts a package of files to a special format (ZIP, 7Z, RAR, etc.), with the Zip tool you can achieve it in this way; The first thing is to install it, depending on your Linux distribution the command varies:

  • “sudo apt install zip”, for Debian and Ubuntu.
  • “sudo yum install zip”, for CentOS and Fedora.
  • “sudo pacman -S zip”, for Arch Linux or Manjaro.
  • “sudo zypper install zip”, for OpenSUSE

Now, the structure to compress a large directory is “ zip -r compressed_file DirectoryToCompress”, each directory or file to be compressed must be separated by a space.

 

What to do to see the available space on your Linux PC?

Monitoring the level of use of your hard disk is quite important to timely manage solutions that allow you to improve its performance, the ideal way to see the available space on your Linux PC is as follows; in a terminal enter the following code “df -h”, with this you will receive a list that indicates the total, used and free space of each file system.

How else can you free up memory?

In addition to reducing the size of directories by compressing them , there are other measures you can take to free up space on your Linux computer and thus improve both performance and memory capacity.

  • Uninstall programs you don’t use: the system automatically identifies and deletes them with “sudo apt-get autoremove”
  • Clear the cache: by executing the command “sudo apt-get clean”
  • Delete unnecessary kernel file: enter the code “sudo apt autoremove – purge”
  • Download a cleaner: BleachBit can be quite useful,
  • Keep your system updated

by Abdullah Sam
I’m a teacher, researcher and writer. I write about study subjects to improve the learning of college and university students. I write top Quality study notes Mostly, Tech, Games, Education, And Solutions/Tips and Tricks. I am a person who helps students to acquire knowledge, competence or virtue.

Leave a Comment