Linux 系统下常用的环境是终端,没有图形化界面使查看文件/文件夹的一些属性没有那么直观,需要配合命令来实现。

使用命令如下:
ls:查看文件大小
du:查看文件夹大小

ls

查看文件大小。

ls -l filename   #显示当前目录下此文件的大小
ls -lh filename  #显示当前目录下此文件的大小,数值显示为适合人们观察的格式, human readable format (kb,mb,gb...)
ls -l *          #显示当前目录下所有文件的大小信息
ls -al *         #显示当前目录下所有文件的大小信息,包括隐藏文件
ls -al /dir/      #显示特定目录下所有文件的大小信息,包括隐藏文件

使用 ls 命令,文件夹的大小会显示此文件夹本身的大小,而不是问价夹内内容的总大小。

du

查看文件夹内容大小

du -sh directory_name    #显示总的 summarized(-s) 目录大小 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

标签:ls, du

你的评论