mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-01 21:50:13 +08:00
Merge pull request #1325 from cvsher/master
Linux Basics: How To Find Size of Directory Commands 翻译完毕
This commit is contained in:
commit
06af54ec58
@ -1,66 +0,0 @@
|
|||||||
cvsher翻译中
|
|
||||||
Linux Basics: How To Find Size of Directory Commands
|
|
||||||
================================================================================
|
|
||||||
This is the first in a series of posts in coming where I’ll be writing about some **basic commands** that that will be of good use to new users.
|
|
||||||
|
|
||||||
**Note**: This is targeted at people little or no command line experience..
|
|
||||||
|
|
||||||
> How can I as a new user to Linux display directory properties from the terminal?
|
|
||||||
|
|
||||||
### Requirements ###
|
|
||||||
|
|
||||||
The only requirement is the **du** command line tool. du comes with almost every Linux distro by default.
|
|
||||||
|
|
||||||
Check if du it’s on your system by running the command below in the terminal:
|
|
||||||
|
|
||||||
man du
|
|
||||||
|
|
||||||
**du** command estimates file space usage
|
|
||||||
|
|
||||||
### Using du ###
|
|
||||||
|
|
||||||
Running du with no flag displays names of all directories including sub-directories and sizes in bytes.
|
|
||||||
|
|
||||||
du
|
|
||||||
|
|
||||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/du-overview.png)
|
|
||||||
|
|
||||||
Using the **-h** flag displays the sizes in human readable format, that is **K, M** and **G** representing **Kilobyte, Megabyte** and **Gigabyte** respectively.
|
|
||||||
|
|
||||||
du - h
|
|
||||||
|
|
||||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/du-h.png)
|
|
||||||
|
|
||||||
To view a specific directory indicate that after du and flag as shown below:
|
|
||||||
|
|
||||||
du -h Mapmaker
|
|
||||||
|
|
||||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/du-h-mapmaker.png)
|
|
||||||
|
|
||||||
Use -c to see grand **total** displayed:
|
|
||||||
|
|
||||||
du -ch
|
|
||||||
|
|
||||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/du-ch.png)
|
|
||||||
|
|
||||||
Use **-s** flag to display only grand total / disk space used for specific directories:
|
|
||||||
|
|
||||||
du -sh Mapmaker Sandbox
|
|
||||||
|
|
||||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/Screenshot-07052014-093858-AM.png)
|
|
||||||
|
|
||||||
See man du for more flags and there uses
|
|
||||||
|
|
||||||
man du
|
|
||||||
|
|
||||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/man-du.png)
|
|
||||||
|
|
||||||
Knows other combinations of du? Share with myself and others here too.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: http://www.unixmen.com/linux-basics-find-size-directory-commands/
|
|
||||||
|
|
||||||
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
|
@ -0,0 +1,63 @@
|
|||||||
|
Linux基础,如何在命令行中查看目录的大小
|
||||||
|
=====================================================================
|
||||||
|
这是写给Liunx新用户的一系列文章中的第一篇,在这系列文章我将会写一些对新用户来说非常好用的**Linux基础命令**。
|
||||||
|
|
||||||
|
**注意**:本文的目标读者是仅有小量甚至是没有任何Linux命令行使用经验的读者。
|
||||||
|
|
||||||
|
>作为一个Linux的新用户,我怎样可以在命令行终端中查看某个目录的属性?
|
||||||
|
|
||||||
|
###要求###
|
||||||
|
|
||||||
|
唯一的要求是**du**命令行工具。du基本上是所有Linux发行版本默认提供的工具。用以下的命令来检查你的系统中是否可以使用du命令:
|
||||||
|
|
||||||
|
man du
|
||||||
|
|
||||||
|
**du** 命令用于输出文件的空间使用情况。
|
||||||
|
|
||||||
|
###使用du###
|
||||||
|
|
||||||
|
不带任何参数的运行du命令会显示当前工作目录以及其子目录的文件名和所占用的空间大小(以字节为单位)。
|
||||||
|
|
||||||
|
du
|
||||||
|
|
||||||
|
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/du-overview.png)
|
||||||
|
|
||||||
|
使用**-h**参数以对用户友好的方式输出文件大小,即分别以**K, M**和**G**来表示**Kb,Mb**和**Gb**
|
||||||
|
|
||||||
|
du -h
|
||||||
|
|
||||||
|
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/du-h.png)
|
||||||
|
|
||||||
|
若想查看某个特定目录的文件大小,则在du命令中指定要查看的目录名,如下:
|
||||||
|
|
||||||
|
du -h Mapmaker
|
||||||
|
|
||||||
|
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/du-h-mapmaker.png)
|
||||||
|
|
||||||
|
使用 **-c** 参数来查看目录所占用磁盘空间的总大小
|
||||||
|
|
||||||
|
du -ch
|
||||||
|
|
||||||
|
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/du-ch.png)
|
||||||
|
|
||||||
|
使用 **-s** 参数只输出指定目录占用空间的大小
|
||||||
|
|
||||||
|
du -sh Mapmaker Sandbox
|
||||||
|
|
||||||
|
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/du-ch.png)
|
||||||
|
|
||||||
|
使用 man du 查看du命令更多参数的用法
|
||||||
|
|
||||||
|
man du
|
||||||
|
|
||||||
|
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/07/man-du.png)
|
||||||
|
|
||||||
|
知道du命令更多的用法?请分享给我和其他人。
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: http://www.unixmen.com/linux-basics-find-size-directory-commands/
|
||||||
|
|
||||||
|
译者:[cvsher](https://github.com/cvsher) 校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user