df
df命令参数功能:复查文件系统的c盘空间占用情况。可以借助该命令来获取硬碟被占用了多少空间,目前还剩下多少空间等信息。
句型:
df [-ahikHTm] [目录或文件名]
选项与参数:
实例1
将系统内所有的文件系统列下来!
[root@www ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/hdc2 9920624 3823112 5585444 41% / /dev/hdc3 4956316 141376 4559108 4% /home /dev/hdc1 101086 11126 84741 12% /boot tmpfs 371332 0 371332 0% /dev/shm
在Linux下边假如df没有加任何选项,这么默认会将系统内所有的(不含特殊显存内的文件系统与swap)都以1Kbytes的容量来列下来!
实例2
将容量结果以易读的容量格式显示下来
[root@www ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/hdc2 9.5G 3.7G 5.4G 41% / /dev/hdc3 4.8G 139M 4.4G 4% /home /dev/hdc1 99M 11M 83M 12% /boot tmpfs 363M 0 363M 0% /dev/shm
实例3
将系统内的所有特殊文件格式及名称都列下来
[root@www ~]# df -aT Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/hdc2 ext3 9920624 3823112 5585444 41% / proc proc 0 0 0 - /proc sysfs sysfs 0 0 0 - /sys devpts devpts 0 0 0 - /dev/pts /dev/hdc3 ext3 4956316 141376 4559108 4% /home /dev/hdc1 ext3 101086 11126 84741 12% /boot tmpfs tmpfs 371332 0 371332 0% /dev/shm none binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc sunrpc rpc_pipefs 0 0 0 - /var/lib/nfs/rpc_pipefs
实例4
将/etc下边的可用的c盘容量以易读的容量格式显示
[root@www ~]# df -h /etc Filesystem Size Used Avail Use% Mounted on /dev/hdc2 9.5G 3.7G 5.4G 41% /
du
Linuxdu命令也是查看使用空间的,并且与df命令不同的是Linuxdu命令是对文件和目录c盘使用的空间的查看linux deepin,还是和df命令有一些区别的linux安装磁盘分区,这儿介绍Linuxdu命令。
句型:
du [-ahskm] 文件或目录名称
选项与参数:
实例1
列举目前目录下的所有文件容量
[root@www ~]# du 8 ./test4 <==每个目录都会列出来 8 ./test2 ....中间省略.... 12 ./.gconfd <==包括隐藏文件的目录 220 . <==这个目录(.)所占用的总量
直接输入du没有加任何选项时,则du会剖析当前所在目录的文件与目录所占用的硬碟空间。
实例2
将文件的容量也列下来
[root@www ~]# du -a 12 ./install.log.syslog <==有文件的列表了 8 ./.bash_logout 8 ./test4 8 ./test2 ....中间省略.... 12 ./.gconfd 220 .
实例3
检测根目录下边每位目录所占用的容量
[root@www ~]# du -sm /* 7 /bin 6 /boot .....中间省略.... 0 /proc .....中间省略.... 1 /tmp 3859 /usr <==系统初期最大就是他了啦! 77 /var
转义*来代表每位目录。
与df不一样的是,du这个命令虽然会直接到文件系统内去搜救所有的文件数据。
fdisk
fdisk是Linux的c盘分区表操作工具。
句型:
fdisk [-l] 装置名称
选项与参数:
实例1
列举所有分区信息
[root@AY120919111755c246621 tmp]# fdisk -l Disk /dev/xvda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/xvda1 * 1 2550 20480000 83 Linux /dev/xvda2 2550 2611 490496 82 Linux swap / Solaris Disk /dev/xvdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x56f40944 Device Boot Start End Blocks Id System /dev/xvdb2 1 2610 20964793+ 83 Linux
实例2
找出你系统中的根目录所在c盘,并查阅该硬碟内的相关信息
[root@www ~]# df / <==注意:重点在找出磁盘文件名而已 Filesystem 1K-blocks Used Available Use% Mounted on /dev/hdc2 9920624 3823168 5585388 41% / [root@www ~]# fdisk /dev/hdc <==仔细看,不要加上数字喔! The number of cylinders for this disk is set to 5005. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): <==等待你的输入!
输入m后,才会看见下边这种命令介绍
Command (m for help): m <== 输入 m 后,就会看到底下这些命令介绍 Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition <==删除一个partition l list known partition types m print this menu n add a new partition <==新增一个partition o create a new empty DOS partition table p print the partition table <==在屏幕上显示分割表 q quit without saving changes <==不储存离开fdisk程序 s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit <==将刚刚的动作写入分割表 x extra functionality (experts only)
离开fdisk时按下qlinux伊甸园,这么所有的动作都不会生效!相反的,按下w就是动作生效的意思。
Command (m for help): p <== 这里可以输出目前磁盘的状态 Disk /dev/hdc: 41.1 GB, 41174138880 bytes <==这个磁盘的文件名与容量 255 heads, 63 sectors/track, 5005 cylinders <==磁头、扇区与磁柱大小 Units = cylinders of 16065 * 512 = 8225280 bytes <==每个磁柱的大小 Device Boot Start End Blocks Id System /dev/hdc1 * 1 13 104391 83 Linux /dev/hdc2 14 1288 10241437+ 83 Linux /dev/hdc3 1289 1925 5116702+ 83 Linux /dev/hdc4 1926 5005 24740100 5 Extended /dev/hdc5 1926 2052 1020096 82 Linux swap / Solaris # 装置文件名 启动区否 开始磁柱 结束磁柱 1K大小容量 磁盘分区槽内的系统 Command (m for help): q
想要不存储离开吗?按下q就对了!不要随意按w啊!
使用p可以列举目前这颗c盘的分割表信息,这个信息的上半部在显示整体c盘的状态。
c盘低格
c盘分割完毕后自然就是要进行文件系统的低格,低格的命令十分的简单,使用mkfs(makefilesystem)命令。
句型:
mkfs [-t 文件系统格式] 装置文件名
选项与参数:
实例1
查看mkfs支持的文件格式
[root@www ~]# mkfs[tab][tab] mkfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.msdos mkfs.vfat
按下两个[tab],会发觉mkfs支持的文件格式如上所示。
实例2
将分区/dev/hdc6(可指定你自己的分区)低格为ext3文件系统:
[root@www ~]# mkfs -t ext3 /dev/hdc6 mke2fs 1.39 (29-May-2006) Filesystem label= <==这里指的是分割槽的名称(label) OS type: Linux Block size=4096 (log=2) <==block 的大小配置为 4K Fragment size=4096 (log=2) 251392 inodes, 502023 blocks <==由此配置决定的inode/block数量 25101 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=515899392 16 block groups 32768 blocks per group, 32768 fragments per group 15712 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: done Creating journal (8192 blocks): done <==有日志记录 Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 34 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. # 这样就创建起来我们所需要的 Ext3 文件系统了!简单明了!
c盘检验
fsck(filesystemcheck)拿来检测和维护不一致的文件系统。
若系统掉电或c盘发生问题,可借助fsck命令对文件系统进行检测。
句型:
fsck [-t 文件系统] [-ACay] 装置名称
选项与参数:
实例1
查看系统有多少文件系统支持的fsck命令:
[root@www ~]# fsck[tab][tab] fsck fsck.cramfs fsck.ext2 fsck.ext3 fsck.msdos fsck.vfat
实例2
强制检查/dev/hdc6分区:
[root@www ~]# fsck -C -f -t ext3 /dev/hdc6 fsck 1.39 (29-May-2006) e2fsck 1.39 (29-May-2006) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information vbird_logical: 11/251968 files (9.1% non-contiguous), 36926/1004046 blocks
假如没有加上-f的选项,则因为这个文件系统不曾出现问题,检测的经过特别快速!若加上-f强制检测,才能一项一项的显示过程。
c盘挂载与卸除
Linux的c盘挂载使用mount命令linux安装磁盘分区,卸载使用umount命令。
c盘挂载句型:
mount [-t 文件系统] [-L Label名] [-o 额外选项] [-n] 装置文件名 挂载点
实例1
用默认的形式,将刚才创建的/dev/hdc6挂载到/mnt/hdc6里面!
[root@www ~]# mkdir /mnt/hdc6 [root@www ~]# mount /dev/hdc6 /mnt/hdc6 [root@www ~]# df Filesystem 1K-blocks Used Available Use% Mounted on .....中间省略..... /dev/hdc6 1976312 42072 1833836 3% /mnt/hdc6
c盘卸载命令umount句型:
umount [-fn] 装置文件名或挂载点
选项与参数:
卸载/dev/hdc6
[root@www ~]# umount /dev/hdc6