
Checking and Saving Folder Sizes in Linux
Checking Folder Sizes
For example, suppose you have a folder named /home/hostingturkiye
. To find out the total size of this folder, you can use the following command:
du -sh /home/hostingturkiye
This command uses du
(disk usage) to show the total size of the specified folder in a summarized and human-readable format (such as K, M, G units).
Saving Results to a File
If you want to save the folder size information to a file, use this command:
du -sh /home/hostingturkiye
> /home/kaydet.txt
This command checks the size of /home/hostingturkiye
and saves the result into /home/kaydet.txt
. Specifying the full path of the file helps you easily locate the result.
More Detailed Usage
If you want to see the sizes of all subfolders within a specific folder, use:
du -h /home/hostingturkiye
This will display detailed sizes of all files and subfolders within the folder, also in a human-readable format.
To save this detailed output to a file, use:
du -h /home/hostingturkiye
> /home/kapsamli_kaydet.txt
This way, the sizes of the specified folder and all its subfolders are saved in /home/kapsamli_kaydet.txt
.
Summary of Useful Commands:
-
Learn folder size: du -sh /path/to/folder
-
Save result to a file: du -sh /path/to/folder > /path/to/file.txt
-
Learn sizes of subfolders: du -h /path/to/folder
-
Save detailed output: du -h /path/to/folder > /path/to/file.txt
These commands provide an effective way to monitor and manage disk usage on your Linux system.