![]() 8 tutorials/target/past/source1/source2ġ00 tutorials Show disk size in human-readable format This is the output for the tutorials directory. Now if I run the du command in the “tutorials” directory, it will show the sizes of all the subdirectories and then sum the sizes of all the subdirectories and the files at the bottom of it. Here’s the structure of the “tutorials” directory I am going to use in this tutorial: tree tutorials Let’s see how to use the du command to get the file and directory size information in Linux. The syntax for the du command is pretty simple. I am going to show you various examples of the du command that you can use to check the directory size and the disk utilization. Using du command to get directory size in Linux This will give you the total size of the said directory in human-readable format, i.e. If you want to check the directory size in Linux, you can use this command: du -sh path_to_directory For the moment, let’s focus on getting the directory size. I’ll explain the logic behind the 4.0K size for the directories later in this tutorial. The size of a folder or directory in Linux can be found using the du command. That cannot be correct, can it be? Of course not. ![]() The ls command shows the size of all the directories as 4 KB. rw-rw-r- 1 abhishek abhishek 55 Mar 11 16:28 text-file.txt rwxrw-r- 1 abhishek abhishek 72 Jan 21 15:44 sleep.shĭrwxr-xr-x 3 abhishek abhishek 4.0K Jan 4 20:10 targetĭrwxr-xr-x 2 abhishek abhishek 4.0K Apr 16 18:27 test_dir rw-r-r- 1 abhishek abhishek 356 Dec 11 21:35 sherlock.txt rw-r-r- 1 abhishek abhishek 19K Mar 18 18:46 services rw-r-r- 1 abhishek abhishek 163 Apr 13 15:07 prog.py rw-rw-r- 1 abhishek abhishek 95 Feb 11 13:12 cpluplus.cpp rwxr-r- 1 abhishek abhishek 140 Mar 22 16:41 bash_script.sh rw-r-r- 1 abhishek abhishek 0 Apr 16 19:53 a.t rwxr-r- 1 abhishek abhishek 456 Mar 6 16:21 agatha.txt All you have to do is to use the -l and -h option with the ls command and it will show you the file size along with file permissions and file timestamps. ![]() Knowing the size of a file is easy in Linux. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |