转载  Linux command: sudo, df,du 收藏

From http://blog.csdn.net/hansel/archive/2008/09/05/2885886.aspx


1.sudo可以避免不断用su来切换不同的用户,如果只是想执行一个root权限的命令的话,使用sudo将是最好的选择。


要能够使用sudo,需要把你的用户名加入到/etc/sudoers文件中,例如增加用户myname:

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
myname    ALL=(ALL)       NOPASSWD: ALL


加了NOPASSWD的目的是不需要在第一次使用sudo时进行用户密码认证。

之后就可以在使用需要root权限的命令前加上sudo 就可以了,例如:

sudo ifconfig eth0 down



2.df :df 使用df命令查看linux磁盘剩余空间


[root]# df -hl
文件系统                        容量        已用       可用       已用% 挂载点
/dev/hda5                    487M     120M       342M   27%    /
/dev/hda1                    981M      21M        911M    3%
/boot none                   125M      0            125M    0%
/dev/shm /dev/hda2     29G        4.9G       23G     18%
/home /dev/hda3          20G        4.8G       14G     27%    /usr
/dev/hda7                     24G        510M       22G    3%      /var
/dev/hdb2                    75G         75G          0       100%   /

df是以磁盘分区为单位来查看文件系统。
/dev/hdb2 75G 75G 0 100% /, 以此为例。
表示HD硬盘接口的第二个硬盘(b),第二个分区(2),容量是75G,用了75G,可用是0,因此利用率是100%, 被挂载到根分区目录上(/)     
另外简单的一个办法就是鼠标右键查看磁盘、文件夹属性,就能了解到已用多少,剩余多少空间。在我自己的开发板上使用的结果



3.du - estimate file space usage


SYNOPSIS
       du [OPTION]... [FILE]...

DESCRIPTION
       Summarize disk usage of each FILE, recursively for directories.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --all
              write counts for all files, not just directories

       --apparent-size
              print  apparent  sizes,  rather  than  disk  usage; although the apparent size is usually smaller, it may be
              larger due to holes in (âsparseâ) files, internal fragmentation, indirect blocks, and the like

       -B, --block-size=SIZE use SIZE-byte blocks

       -b, --bytes
              equivalent to â--apparent-size --block-size=1â

           -H     like --si, but also evokes a warning; will soon change to be equivalent to --dereference-args (-D)

       -h, --human-readable
              print sizes in human readable format (e.g., 1K 234M 2G)

       --si   like -h, but use powers of 1000 not 1024

       -k     like --block-size=1K

       -l, --count-links
              count sizes many times if hard linked

       -L, --dereference
              dereference all symbolic links

       -P, --no-dereference
              donât follow any symbolic links (this is the default)

       -0, --null
              end each output line with 0 byte rather than newline

       -S, --separate-dirs
              do not include size of subdirectories

       -s, --summarize
              display only a total for each argument

       -x, --one-file-system
              skip directories on different filesystems

       -X FILE, --exclude-from=FILE
              Exclude files that match any pattern in FILE.

判断一个文件夹多大:

du -sh foldername


发表于 @ 2009年05月21日 11:50:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:Linux Mount 命令的使用(整理) | 新一篇:linux : if (&&) and mail 用法

  • 发表评论
  • 评论内容:
  •  
Copyright © dingxy
Powered by CSDN Blog