![]() If you have any questions or remarks, leave a comment below. In Linux, you can get the size of a directory using the du command. Within the /var directory, you would pipe the output of du to the sort command to sort the directories by their size and then pipe the output to the headĬommand that will print only the top 5 directories: sudo du -h /var/ | sort -rh | head -5 85G /var/ The du command can also be combined with other commands with pipes.įor example, to print the 5 largest directories This is why the size of space on the disk used on the source when displayed with du (without -apparent-size) is not the same as the size on the target. The amount of data that is transferred over the network is the apparent size of the files. The “apparent size” of a file is how much data is actually in the file. To find the apparent size of a directory, use the -apparent-size option. The -c option tells du to print a grand total of all sizes: sudo du -shc /var/* 24K /var/dbĪnother way to get a report about the disk usage of the first-level subdirectories is to use the -max-depth option: sudo du -h -max-depth=1 /var 77G /var/libīy default, the du command shows the disk space used by the directory or file. The first one is to use the asterisk symbol ( *) as shown below, which means “match everything that doesn’t start with a period (. What if you want to display the disk usage of the first-level subdirectories? You have two options. /var - The path to the directory you want to get the size.h - Print sizes in a human-readable format ( h).s - Display only the total size of the specified directory, do not display file size totals for subdirectories.The du command will print “du: cannot read directory”. The command starts with sudo because most of the files and directories inside the /var directory are owned by the root user and are not readable by the regular users.Let’s explain the command and its arguments: The output will look something like this: 85G /var ![]() For example, to get the total size of the /var directory, you would run the following command: sudo du -sh /var Typically, you would want to display the space occupied by the directory in a human-readable format. When invoked without any options, du displays the disk usage of the given directory and each of its subdirectories in bytes. If no path is specified, du reports the disk usage of the current working directory If the specified path is a directory, du summarizes disk usage of each subdirectory in that directory. Getting the Size of a Directory #Ĭommand displays the amount of file space used by the specified files or directories. The command you’ll want to use to get the actual size of a directory is du, which is short for “disk usage”. That’s the size of space on the disk that is used to store the meta-information for the directory, not what it contains. Access to mobile devices (e.g.When listing the contents of a directory using the lsĬommand, you may have noticed that the size of the directories is almost always 4096 bytes (4 KB).Simple FTP/SFTP client (SFTP only 64 bit).User defined columns for detailed views.File filters (regexp possible too) for display and file operations.Modification of file date and attributes. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |