Linux 磁盘管理命令

    技术2022-05-20  36

    功能:检查文件系统的磁盘空间占用情况。可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信息。  语法:df [选项]  说明:df命令可显示所有文件系统对i节点和磁盘块的使用情况。  该命令各个选项的含义如下:  -a 显示所有文件系统的磁盘使用情况,包括0块(block)的文件系统,如/proc文件系统。  -k 以k字节为单位显示。  -i 显示i节点信息,而不是磁盘块。  -t 显示各指定类型的文件系统的磁盘空间使用情况。  -x 列出不是某一指定类型文件系统的磁盘空间使用情况(与t选项相反)。  -T 显示文件系统类型。

     

    rcc-pok-idg-2318:~ # df -i -x tmpfs Filesystem            Inodes   IUsed   IFree IUse% Mounted on /dev/vda1            2099088  112652 1986436    6% / rcc-pok-idg-2318:~ # df -iT -t vfat -t ext3 Filesystem    Type    Inodes   IUsed   IFree IUse% Mounted on /dev/vda1     ext3   2099088  112652 1986436    6% /

     

    du命令:

    rcc-pok-idg-2318:~ # du --help Usage: du [OPTION]... [FILE]...   or:  du [OPTION]... --files0-from=F 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'   -c, --total           produce a grand total   -D, --dereference-args  dereference only symlinks that are listed on the                           command line       --files0-from=F   summarize disk usage of the NUL-terminated file                           names specified in file F   -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   -m                    like --block-size=1M   -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 file systems   -X FILE, --exclude-from=FILE  Exclude files that match any pattern in FILE.       --exclude=PATTERN  Exclude files that match PATTERN.       --max-depth=N     print the total for a directory (or file, with --all)                           only if it is N or fewer levels below the command                           line argument;  --max-depth=0 is the same as                           --summarize       --time            show time of the last modification of any file in the                           directory, or any of its subdirectories       --time=WORD       show time as WORD instead of modification time:                           atime, access, use, ctime or status       --time-style=STYLE  show times using style STYLE:                           full-iso, long-iso, iso, +FORMAT                           FORMAT is interpreted like `date'       --help     display this help and exit       --version  output version information and exit SIZE may be (or may be an integer optionally followed by) one of following: kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. Report bugs to <bug-coreutils@gnu.org>.

     

    rcc-pok-idg-2318:~ # du -hc * 4.0K    Desktop 20K     Documents 4.0K    bin 20K     inst-sys/.yast2 8.0K    inst-sys/.gnupg 8.0K    inst-sys/.config 56K     inst-sys 84K     total rcc-pok-idg-2318:~ # du -hs 15M     .

     

     

    fsck命令:

     

    fsck 1.41.1 (01-Sep-2008) fsck.ext3: invalid option -- 'h' Usage: fsck.ext3 [-panyrcdfvtDFV] [-b superblock] [-B blocksize]                 [-I inode_buffer_blocks] [-P process_inode_size]                 [-l|-L bad_blocks_file] [-C fd] [-j external_journal]                 [-E extended-options] device Emergency help:  -p                   Automatic repair (no questions)  -n                   Make no changes to the filesystem  -y                   Assume "yes" to all questions  -c                   Check for bad blocks and add them to the badblock list  -f                   Force checking even if filesystem is marked clean  -v                   Be verbose  -b superblock        Use alternative superblock  -B blocksize         Force blocksize when looking for superblock  -j external_journal  Set location of the external journal  -l bad_blocks_file   Add to badblocks list  -L bad_blocks_file   Set badblocks list

     

     

    Linux fstab命令的理解:

     

    rcc-pok-idg-2318:~ # cat /etc/fstab /dev/vda1            /                    ext3       acl,user_xattr        1 1 /dev/vda2            swap                 swap       defaults              0 0 proc                 /proc                proc       defaults              0 0 sysfs                /sys                 sysfs      noauto                0 0 debugfs              /sys/kernel/debug    debugfs    noauto                0 0 usbfs                /proc/bus/usb        usbfs      noauto                0 0 devpts               /dev/pts             devpts     mode=0620,gid=5    

     

     

    第一列表示 file system

    第二列表示挂载点

    第三列表示文件类型

     

    第5列为dump选项,设置是否让备份程序dump备份文件系统,0为忽略,1为备份。 第6列为fsck选项,告诉fsck程序以什么顺序检查文件系统,0为忽略。

     

    lsof: lsof - list open files

     

    基本描述:查看系统/进程所占资源

    语法:lsof[选择参数][文件]

    功能:lsof 命令:用于查看你进程开打的文件,打开文件的进程,进程打开的端口(TCP、UDP)。找回/恢复删除的文件。是十分方便的系统监视工具,因为 lsof 需要访问核心内存和各种文件,所以需要root用户执行

    参数:

    -a     列出打开文件存在的进程 -c<进程名> 列出指定进程所打开的文件 -g 列出GID号进程详情 -d<文件号> 列出占用该文件号的进程 +d<目录> 列出目录下被打开的文件 +D<目录> 递归列出目录下被打开的文件 -n<目录> 列出使用NFS的文件 -i<条件> 列出符合条件的进程。(4、6、协议、:端口、 @ip ) -p<进程号> 列出指定进程号所打开的文件 -u 列出UID号进程详情

    -h 显示帮助信息 -v 显示版本信息

     


    最新回复(0)