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

how-can-i-see-the-size-of-files-and-directories-in-linux的更多相关文章

  1. 10 Useful du (Disk Usage) Commands to Find Disk Usage of Files and Directories

    The Linux “du” (Disk Usage) is a standard Unix/Linux command, used to check the information of disk ...

  2. Files and Directories

    Files and Directories Introduction     In the previous chapter we coveredthe basic functions that pe ...

  3. Notes for Apue —— chapter 4 Files and Directories(文件和目录)

    4.1 Introduction 4.2 stat, fstat, fstatat, and lstat Functions The lstat function is similar to stat ...

  4. 【原】The Linux Command Line - Manipulation Files And Directories

    cp - Copy Files and directories mv - move/rename files and directories mkdir - create directories rm ...

  5. How to ignore files and directories in subversion?

    Step 1 Copy the files and directories to other place. Step 2 Delete the files and directories. Step ...

  6. Getting svn to ignore files and directories

    August 27, 2013Software Developmentresources, subversion, svn, tutorial, version control Who knew it ...

  7. Finding files on a *nix/Linux and sorting by size

    1. Finding files on *NIX and sort by size find ~ -iregex ".*/*.sh" -type f -print0 | xargs ...

  8. UNIX高级环境编程(4)Files And Directories - umask、chmod、文件系统组织结构和链接

    本篇主要介绍文件和文件系统中常用的一些函数,文件系统的组织结构和硬链接.符号链接. 通过对这些知识的了解,可以对Linux文件系统有更为全面的了解.   1 umask函数 之前我们已经了解了每个文件 ...

  9. UNIX高级环境编程(5)Files And Directories - 文件相关时间,目录文件相关操作

     1 File Times 每个文件会维护三个时间字段,每个字段代表的时间都不同.如下表所示: 字段说明: st_mtim(the modification time)记录了文件内容最后一次被修改的时 ...

  10. UNIX高级环境编程(3)Files And Directories - stat函数,文件类型,和各种ID

    在前面的两篇,我们了解了IO操作的一些基本操作函数,包括open.read和write. 在本篇我们来学习一下文件系统的其他特性和一个文件的属性,涉及的函数功能包括: 查看文件的所有属性: 改变文件所 ...

随机推荐

  1. 动态 Web Server 技术发展历程

    动态 Web Server 技术发展历程 开始接触 Java Web 方面的技术,此篇文章是以介绍 Web server 相关技术的演变为主来作为了解 Java servlet 的技术背景,目的是更好 ...

  2. Eclipse更新慢、插件安装慢解决方案zz

    步骤 Eclipse -> Help -> Install New Software... 在出现的窗口点击Available Software Sites链接 将所有URL中的" ...

  3. iOS中 H5的input输入框focus()无法自动拉起键盘(解决方法)

    ios的hybird APP 无法使用focus()获取焦点和键盘的问题. 解决方案 原来,在App的配置文件(config.xml),里面默认会有一句 1 <preference name=& ...

  4. PIVOT和UNPIVOT使用详解

    一.使用PIVOT实现数据表的列转行 建表语句: DROP TABLE STUDENT; CREATE TABLE STUDENT ( 学生编号 BYTE) NULL , 姓名 BYTE) NULL ...

  5. Apache自带压力测试工具----linux环境中ab命令简介及结果分析

    ab(apache bench)是apache下的一个工具,主要用于对web站点做压力测试, 基础用法: 其中-c选项为一次发送的请求数量,及并发量.-n选项为请求次数. 实验测试: [dev@web ...

  6. 用STM32CudeMX 点亮红色LED灯(软件操作步骤为主)

    1.收获如何使用软件STM32CudeMX配置代码 注意:自己要敲的代码,直接看102行,其他是软件配置的.!!! /** ************************************** ...

  7. 20172327 2018-2019-1 《第一行代码Android》第一章学习总结

    学号 2018-2019-1 <第一行代码Android>第一章学习总结 教材学习内容总结 - Android系统架构: 1.Linux内核层 Android系统是基于Linux内核的,这 ...

  8. Sunday串匹配算法 C语言实现

    unsigned char * sunday( void * a_buf1, unsigned int len1, void * a_buf2, unsigned int len2 ){ unsign ...

  9. Java 泛型 介绍

    为什么需要泛型? public class GenericTest { public static void main(String[] args) { List list = new ArrayLi ...

  10. PAT Basic 1002

    1002 写出这个数 (20 分) 读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字. 输入格式: 每个测试输入包含 1 个测试用例,即给出自然数 n 的值.这里保证 n 小于 1 ...