How to see which Linux directory is taking up the most space? – storage

Linux is an operating system that increases the number of users every day, due to its stability, speed and cost (completely free), as free software it allows you to manage processes more broadly implement.For example, check and control directories, as these can take up a lot of hard drive space and affect the overall performance of the PC, in case you were wondering Which files are taking up your computer’s memory? How much space do they take up? Read on as we explain below.

laptop with linux

How can I see the largest folders using the du command?

The DU command is short for «Disk Usage», so obviously it refers to using your computer’s disk, its purpose is Quantify the occupancy of a directory or files, on your hard drive. To do this, you must do the following:

  1. Open a terminal and press the «Ctrl + Alt + T» keys simultaneously.
  2. Enter a command with the following structure»du -a /directory_name | sort -n -r | head -n 7«, remember to replace the «DirectoryName» part with the name of the folder where you want to find the most important directories.
  3. Instead, if you want to search the heaviest directory in the whole system, the code you should execute is something like this «dua | sort -n -r | head -n 7» or «du -hs * | sort -rh | head -7», Search in subdirectories.

The system returns a list with home directories, according to their space consumption on the hard drive, explained as follows, the first column refers to the size of the file on the hard drive (in the last code, in units of storage), then each path or name, another consideration is, will show as many directory lines as the last number Statement example 7. Remember the directory with the most weight, it’s the first directory shown in the list.

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

Linux Find is a very useful command perform functions to find files and directories, Under Grading Criteria and Optimizing Resources. The way it manages to check your system is through a strict syntax consisting of a hyphen (-) followed by the parameter/filter to apply (name, type, owner, size, etc.), a space () and selected parameters.

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

  • Look for. » to search the current folder.
  • find~ » to search in the current user’s folders.

man using laptop at table

What are the steps required to use the find command to see the largest files in Linux?

Follow this structure to know exactly which files are most important in your Linux OS; run «find -type f -exec du -Sh {} + | sort -rh | head -n 7″, As with the previous commands, the last number determines the number of results you will see, in this case you will see the 7 largest directories.

The first number is automatically displayed as the unit of measure, as it represents dimensions in ascending order, and you’ll see the name of each number.Otherwise, if you need Search within the specified paththe command must be modified to «find /RutaDeldirectorio -type f -exec du -Sh {} + | sort -rh | head -n 7», remember to replace with the desired path.

How to compress the space occupied by folders in Linux?

When determining which folder or file on your PC is taking up the most space, you may be wondering what you can do, if so, try Compress the offending folder so that it takes up less space. Compressing a folder in Linux is a simple task, it converts the file package into a special format (ZIP, 7Z, RAR, etc.), using the Zip tool you can do it this way; the first is to install it, depending on your Linux distribution, the command will be different:

  • «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 of the compressed re-directory is «zip -r compress the file DirectoryToCompress», Each directory or file to be compressed must be separated by a space.

man typing on laptop

How can I check the free space on my Linux PC?

Monitoring the usage level of your hard drive is very important for timely management of solutions that allow you to improve its performance, the ideal way to see the free space on your Linux PC is as follows; enter the following code «df -h» in the terminal and you will receive a list, Indicates the total space, used space, and free space for each file system.

Is there any way to free the memory?

also Reduce the size of a directory by compressing ityou can take additional steps to free up space on your Linux computer to improve performance and memory capacity

  • Uninstall unused programs: The system automatically recognizes and removes using «sudo apt-get autoremove»
  • Clear the cache: by executing the command «sudo apt-get clean»
  • Remove unwanted kernel files: enter the code «sudo apt autoremove — purge»
  • Download Cleaner: BleachBit is very useful,
  • Keep your system up to date.

Deja un comentario