- 浏览: 2075695 次
- 性别:
- 来自: NYC
文章分类
- 全部博客 (628)
- Linux (53)
- RubyOnRails (294)
- HTML (8)
- 手册指南 (5)
- Mysql (14)
- PHP (3)
- Rails 汇总 (13)
- 读书 (22)
- plugin 插件介绍与应用 (12)
- Flex (2)
- Ruby技巧 (7)
- Gem包介绍 (1)
- javascript Jquery ext prototype (21)
- IT生活 (6)
- 小工具 (4)
- PHP 部署 drupal (1)
- javascript Jquery sort plugin 插件 (2)
- iphone siri ios (1)
- Ruby On Rails (106)
- 编程概念 (1)
- Unit Test (4)
- Ruby 1.9 (24)
- rake (1)
- Postgresql (6)
- ruby (5)
- respond_to? (1)
- method_missing (1)
- git (8)
- Rspec (1)
- ios (1)
- jquery (1)
- Sinatra (1)
最新评论
-
dadadada2x:
user模型里加上 protected def email ...
流行的权限管理 gem devise的定制 -
Sev7en_jun:
shrekting 写道var pattern = /^(0| ...
强悍的ip格式 正则表达式验证 -
jiasanshou:
好文章!!!
RPM包rpmbuild SPEC文件深度说明 -
寻得乐中乐:
link_to其实就是个a标签,使用css控制,添加一个参数: ...
Rails在link_to中加参数 -
aiafei0001:
完全看不懂,不知所然.能表达清楚一点?
"$ is not defined" 的问题怎么办
du -sh `ls .`
for i in G M K; do du -ah | grep [0-9]$i | sort -nr -k 1; done | head -n 11
dir | gvim -
df -k .
Show size of current directory in
df -h | grep /dev/hda1 | cut -c 41-43
du -ch | grep total
How to find - Size of a directory & Free disk space
This article explains 2 simple commands that most people want to know when they start using Linux. They are finding the size of a directory and finding the amount of free disk space that exists on your machine. The command you would use to find the directory size is ' du '. And to find the free disk space you could use ' df '.
All the information present in this article is available in the man pages for du and df. In case you get bored reading the man pages and you want to get your work done quickly, then this article is for you.
-
'du' - Finding the size of a directory
$ du
Typing the above at the prompt gives you a list of directories that exist in the current directory along with their sizes. The last line of the output gives you the total size of the current directory including its subdirectories. The size given includes the sizes of the files and the directories that exist in the current directory as well as all of its subdirectories. Note that by default the sizes given are in kilobytes.
$ du /home/david
The above command would give you the directory size of the directory /home/david
$ du -h
This command gives you a better output than the default one. The option '-h' stands for human readable format. So the sizes of the files / directories are this time suffixed with a 'k' if its kilobytes and 'M' if its Megabytes and 'G' if its Gigabytes.
$ du -ah
This command would display in its output, not only the directories but also all the files that are present in the current directory. Note that 'du' always counts all files and directories while giving the final size in the last line. But the '-a' displays the filenames along with the directory names in the output. '-h' is once again human readable format.
$ du -c
This gives you a grand total as the last line of the output. So if your directory occupies 30MB the last 2 lines of the output would be
30M .
30M total
The first line would be the default last line of the 'du' output indicating the total size of the directory and another line displaying the same size, followed by the string 'total'. This is helpful in case you this command along with the grep command to only display the final total size of a directory as shown below.
$ du -ch | grep total
This would have only one line in its output that displays the total size of the current directory including all the subdirectories.
Note : In case you are not familiar with pipes (which makes the above command possible) refer to Article No. 24 . Also grep is one of the most important commands in Unix. Refer to Article No. 25 to know more about grep.
$ du -s
This displays a summary of the directory size. It is the simplest way to know the total size of the current directory.
$ du -S
This would display the size of the current directory excluding the size of the subdirectories that exist within that directory. So it basically shows you the total size of all the files that exist in the current directory.
$ du --exculde=mp3
The above command would display the size of the current directory along with all its subdirectories, but it would exclude all the files having the given pattern present in their filenames. Thus in the above case if there happens to be any mp3 files within the current directory or any of its subdirectories, their size would not be included while calculating the total directory size.
-
'df' - finding the disk free space / disk usage
$ df
Typing the above, outputs a table consisting of 6 columns. All the columns are very easy to understand. Remember that the 'Size', 'Used' and 'Avail' columns use kilobytes as the unit. The 'Use%' column shows the usage as a percentage which is also very useful.
$ df -h
Displays the same output as the previous command but the '-h' indicates human readable format. Hence instead of kilobytes as the unit the output would have 'M' for Megabytes and 'G' for Gigabytes.
Most of the users don't use the other parameters that can be passed to 'df'. So I shall not be discussing them.
I shall in turn show you an example that I use on my machine. I have actually stored this as a script named 'usage' since I use it often.
Example :
I have my Linux installed on /dev/hda1 and I have mounted my Windows partitions as well (by default every time Linux boots). So 'df' by default shows me the disk usage of my Linux as well as Windows partitions. And I am only interested in the disk usage of the Linux partitions. This is what I use :
$ df -h | grep /dev/hda1 | cut -c 41-43
This command displays the following on my machine
45%
Basically this command makes 'df' display the disk usages of all the partitions and then extracts the lines with /dev/hda1 since I am only interested in that. Then it cuts the characters from the 41st to the 43rd column since they are the columns that display the usage in % , which is what I want.
Note : In case you are not familiar with pipes (which is used in the above command) then refer to Article No. 24 . 'cut' is another tool available in Unix. The above usage of cut gets the the characters that are present in the specified columns. If you are interested in knowing how to mount you Windows partitions under Linux, please refer to Article No. 3 .
There are a few more options that can be used with 'du' and 'df' . You could find them in the man pages.
for i in G M K; do du -ah | grep [0-9]$i | sort -nr -k 1; done | head -n 11
dir | gvim -
#output to vim #the - option tells vim to open stdin dir | gvim - #inside vim :r !<cmd> :r !dir
df -k .
Show size of current directory in
du -sh `ls .` du -h | tail -n 1 du -h | grep -v '/' | awk '{print $1}' ls | wc -l ls -l | grep ^- | wc -l ls -l | grep ^d | wc -l ls -l | grep ^l | wc -l for t in files links directories; do echo `find . -type ${t:0:1} | wc -l` $t; done 2> /dev/null du -a | cut -d/ -f2 | sort | uniq -c | sort -nr find . -type f | wc -l ind . -type d | wc -l find . -maxdepth 1 -type d | wc -l
df -h | grep /dev/hda1 | cut -c 41-43
du -ch | grep total
How to find - Size of a directory & Free disk space
This article explains 2 simple commands that most people want to know when they start using Linux. They are finding the size of a directory and finding the amount of free disk space that exists on your machine. The command you would use to find the directory size is ' du '. And to find the free disk space you could use ' df '.
All the information present in this article is available in the man pages for du and df. In case you get bored reading the man pages and you want to get your work done quickly, then this article is for you.
-
'du' - Finding the size of a directory
$ du
Typing the above at the prompt gives you a list of directories that exist in the current directory along with their sizes. The last line of the output gives you the total size of the current directory including its subdirectories. The size given includes the sizes of the files and the directories that exist in the current directory as well as all of its subdirectories. Note that by default the sizes given are in kilobytes.
$ du /home/david
The above command would give you the directory size of the directory /home/david
$ du -h
This command gives you a better output than the default one. The option '-h' stands for human readable format. So the sizes of the files / directories are this time suffixed with a 'k' if its kilobytes and 'M' if its Megabytes and 'G' if its Gigabytes.
$ du -ah
This command would display in its output, not only the directories but also all the files that are present in the current directory. Note that 'du' always counts all files and directories while giving the final size in the last line. But the '-a' displays the filenames along with the directory names in the output. '-h' is once again human readable format.
$ du -c
This gives you a grand total as the last line of the output. So if your directory occupies 30MB the last 2 lines of the output would be
30M .
30M total
The first line would be the default last line of the 'du' output indicating the total size of the directory and another line displaying the same size, followed by the string 'total'. This is helpful in case you this command along with the grep command to only display the final total size of a directory as shown below.
$ du -ch | grep total
This would have only one line in its output that displays the total size of the current directory including all the subdirectories.
Note : In case you are not familiar with pipes (which makes the above command possible) refer to Article No. 24 . Also grep is one of the most important commands in Unix. Refer to Article No. 25 to know more about grep.
$ du -s
This displays a summary of the directory size. It is the simplest way to know the total size of the current directory.
$ du -S
This would display the size of the current directory excluding the size of the subdirectories that exist within that directory. So it basically shows you the total size of all the files that exist in the current directory.
$ du --exculde=mp3
The above command would display the size of the current directory along with all its subdirectories, but it would exclude all the files having the given pattern present in their filenames. Thus in the above case if there happens to be any mp3 files within the current directory or any of its subdirectories, their size would not be included while calculating the total directory size.
-
'df' - finding the disk free space / disk usage
$ df
Typing the above, outputs a table consisting of 6 columns. All the columns are very easy to understand. Remember that the 'Size', 'Used' and 'Avail' columns use kilobytes as the unit. The 'Use%' column shows the usage as a percentage which is also very useful.
$ df -h
Displays the same output as the previous command but the '-h' indicates human readable format. Hence instead of kilobytes as the unit the output would have 'M' for Megabytes and 'G' for Gigabytes.
Most of the users don't use the other parameters that can be passed to 'df'. So I shall not be discussing them.
I shall in turn show you an example that I use on my machine. I have actually stored this as a script named 'usage' since I use it often.
Example :
I have my Linux installed on /dev/hda1 and I have mounted my Windows partitions as well (by default every time Linux boots). So 'df' by default shows me the disk usage of my Linux as well as Windows partitions. And I am only interested in the disk usage of the Linux partitions. This is what I use :
$ df -h | grep /dev/hda1 | cut -c 41-43
This command displays the following on my machine
45%
Basically this command makes 'df' display the disk usages of all the partitions and then extracts the lines with /dev/hda1 since I am only interested in that. Then it cuts the characters from the 41st to the 43rd column since they are the columns that display the usage in % , which is what I want.
Note : In case you are not familiar with pipes (which is used in the above command) then refer to Article No. 24 . 'cut' is another tool available in Unix. The above usage of cut gets the the characters that are present in the specified columns. If you are interested in knowing how to mount you Windows partitions under Linux, please refer to Article No. 3 .
There are a few more options that can be used with 'du' and 'df' . You could find them in the man pages.
发表评论
-
在ubuntu中.profile 和.bashrc的加载区别
2013-06-01 21:38 2532总之,profile不只是bash,在启动加载 bashrc是 ... -
ubuntu 12.10 proxy install package apt-get
2013-01-31 06:47 1211#/.bashrc export http_proxy= ... -
查找多文件内容替换
2012-09-14 20:58 1497UPDATE: (05/03/2013) 当前使用: # ... -
shell script
2012-09-11 21:08 1042select r.name, count(p.id) from ... -
定期清空日志文件
2012-09-11 10:04 3352一个关于如何在指定文件大于1GB后,自动删除的问题。 批处理代 ... -
查看一个进程占用了那个端口
2012-09-11 09:59 1723有时候需要在Linux下查看一个进程占用了那个端口,但是只知道 ... -
utf8 ruby1.9
2012-07-13 01:57 1338引用invalid byte sequence in utf- ... -
VIM下跳转的区别
2012-05-06 00:33 1393VIM在开tag和jumplist的时候有几个差别 经常用的 ... -
shell command
2012-04-11 21:42 926ls -l . | egrep -c '^d' ls -l . ... -
unbuntu 查看什么占着80端口
2012-01-19 12:37 1441sudo lsof -i :80 sudo nets ... -
处理僵尸进程
2011-05-27 01:45 1175#!/bin/sh kill -HUP `ps -A - ... -
ubuntu 看硬件配置
2011-05-02 02:03 5287总是忘记阿,标记一下 sudo lspci -v lshw ... -
no such file to load -- zlib
2011-04-25 23:52 2758或者提示 fatal error: zlib.h: No su ... -
新装的mysql出现无法登陆的问题 er 1405 参考下面的解决
2011-01-23 12:39 3089Installing MySQL 5.0 First we ... -
ssh无密码登入设置
2010-08-17 21:02 1405现有2台机器 1、服务器192.168.1.112 2、个人机 ... -
bash和乱码
2010-08-16 00:15 1910几个bash下配置的区别 1)/etc/profile: 此文 ... -
ubuntu 配置git服务器及其它
2010-08-15 23:46 2179update: 生产public key的时候不能按照git ... -
nohup命令让程序在后台运行-linux
2010-02-04 14:17 7054nohup ruby /sunrise/www/realwor ... -
shell 条件可能用到
2010-01-26 15:05 1534为什么不能用ruby脚本写啊,shell脚本写的俺很烦啊... ... -
shell脚本和case 使用相关的例子
2010-01-22 17:25 34318支(case与select结构) case ...
相关推荐
Android 命令行工具(commandlinetools-linux-11076708_latest.zip)适用于Linux系统。 如果不需要 Android Studio,可以下载 Android 命令行工具。可以使用包含sdkmanager的下载其他 SDK 包。该工具包含在 Android ...
Android 命令行工具(commandlinetools-linux-8092744_latest.zip)适用于Linux系统。 如果不需要 Android Studio,可以下载 Android 命令行工具。可以使用包含sdkmanager的下载其他 SDK 包。该工具包含在 Android ...
Android 命令行工具(commandlinetools-linux-8512546_latest.zip)适用于Linux系统。 如果不需要 Android Studio,可以下载 Android 命令行工具。可以使用包含sdkmanager的下载其他 SDK 包。该工具包含在 Android ...
If you do not need Android Studio, you can download the basic Android command line tools below. You can use the included sdkmanager to download other SDK packages. These tools are included in Android...
标题中的"commandlinetools-linux-7583922_latest.zip"指的是Android的命令行工具包,这是Google提供的一套用于管理Android SDK的工具集合。这些工具允许开发者在命令行界面执行各种任务,包括但不限于安装、更新、...
在给定的压缩包"HarmonyOS(commandline-tools-linux-2.0.0.2.zip)"中,包含的是HarmonyOS的命令行工具,主要用于开发者在Linux环境下对系统进行构建、编译、调试等操作。这些工具是开发和维护HarmonyOS应用程序不...
Command Line Tools(commandline-tools-linux-x64-5.0.3.900.zip)适用于Linux系统,集合了HarmonyOS应用开发所用到的系列工具,包括代码检查codelinter、三方库包管理ohpm、命令行解析hstack、编译构建hvigorw。...
Android 命令行工具(commandlinetools-linux-10406996_latest.zip)适用于Linux系统。 如果不需要 Android Studio,可以下载 Android 命令行工具。可以使用包含sdkmanager的下载其他 SDK 包。该工具包含在 Android ...
Android 命令行工具(commandlinetools-linux-9477386_latest.zip)适用于Linux系统。 如果不需要 Android Studio,可以下载 Android 命令行工具。可以使用包含sdkmanager的下载其他 SDK 包。该工具包含在 Android ...
HUAWEI DevEco Studio (Command Line Tools)适用于Linux系统 ,Command Line Tools是一系列开发工具的集合,可通过其中的sdkmgr工具查看、安装/更新和卸载多个HarmonyOS SDK包。支持通过自动化构建脚本调用。
标题中的"commandlinetools-win-6609375_latest.zip"表明这是一个针对Windows平台的Android SDK命令行工具的压缩包,版本号为6609375的最新版。这些工具是Android开发者必备的,它们允许开发者在没有图形用户界面的...
Android 命令行工具(commandlinetools-win-11076708_latest.zip)适用于Windows系统。 如果不需要 Android Studio,可以下载 Android 命令行工具。可以使用包含sdkmanager的下载其他 SDK 包。该工具包含在 Android ...
If you do not need Android Studio, you can download the basic Android command line tools below. You can use the included sdkmanager to download other SDK packages. These tools are included in Android...
如果您不需要 Android Studio,可以下载 Android 命令行工具。可以使用包含sdkmanager的下载其他 SDK 包。该工具包含在 Android Studio 中。Android 命令行工具适用于Linux系统。
命令行参数 -q, --quality [value]{必需} 设置图像的质量。值越高,结果越好。请注意,值为 0 表示 无损压缩,不会修改原始图像,但会压缩较少。允许的范围是 [0。100]。 有损压缩的常见值为 80。...
Android 命令行工具(commandlinetools-linux-9123335-latest.zip)适用于Linux系统。如果不需要 Android Studio,可以下载 Android 命令行工具。可以使用包含sdkmanager的下载其他 SDK 包。该工具包含在 Android ...
标题“Linux Command Tools”指的是一个特别设计的工具,它允许用户在Windows操作系统环境下直接执行Linux命令,无需安装完整的Linux发行版。这个工具对于那些经常在Windows和Linux系统间切换的用户来说非常方便,...
标题中的"commandlinetools-win-7583922_latest.zip"表明这是一个针对Windows平台的Android命令行工具包的最新版本。这个压缩包包含了用于Android开发和管理的一系列命令行工具,由谷歌官方提供,是Android SDK的一...
Linux_command_line, Linux命令和 shell 脚本简介 LinuxLinux命令和 shell 脚本简介为更完整的资源列表,包括初学者的教程, Linux Linux curated资源列表有关资源的更多信息,请访问脚本教程。 Linux介绍插件什么是...