how-can-i-see-the-size-of-files-and-directories-in-linux

https://stackoverflow.com/questions/11720079/how-can-i-see-the-size-of-files-and-directories-in-linux

It's simple. Use ls command for files and du command for directories.

Checking File Sizes

ls -l filename /* Size of the file*/
ls -l *        /* Size of All the files in the current directory */
ls -al *       /* Size of All the files including hidden files in the current directory */
ls -al dir/    /* Size of All the files including hidden files in the 'dir' directory */

ls command will not list the actual size of directories(why?). Therefore, we use du for this purpose.

Checking Directory sizes

du -sh directory_name    /* Gives you the summarized(-s) size of the directory in human readable(-h) format*/
du -bsh *                /* Gives you the apparent(-b) summarized(-s) size of all the files and directories in the current directory in human readable(-h) format*/

Including -h option in any of the above commands (for Ex: ls -lh * or du -sh) will give you size in human readable format (kbmb,gb, ...)

For more information see man ls and man du

猜你喜欢

转载自www.cnblogs.com/WCFGROUP/p/10334357.html
今日推荐