linux学习命令总结⑩②
#fdisk命令:磁盘分区工具
fdisk –l:查看机器所挂硬盘个数及分区情况
[root@VM_168_102_centos ~]# fdisk -lDisk /dev/xvda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 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: 0x70068116Device Boot Start End Blocks Id System /dev/xvda1 * 1 1044 8385898+ 83 LinuxDisk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0x00000000Disk /dev/xvdc: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 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
针对某一个挂载设别查看:
[root@VM_168_102_centos ~]# fdisk -l /dev/xvdaDisk /dev/xvda: 8589 MB, 8589934592 bytes #该设备空间80G 255 heads, 63 sectors/track, 1044 cylinders #255个磁头;63个扇区;1044个柱面 Units = cylinders of 16065 * 512 = 8225280 bytes #每个柱面的大小约为8.225280M Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x70068116Device#分区序列 Boot#引导 Start#开始柱面 End#结束柱面 Blocks#容量 Id#分区类型ID System#分区类型 /dev/xvda1 * 1 1044 8385898+ 83 Linux
通过fdisk分区工具,对指定挂载设备进行操作:
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xcc40c7dc. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)WARNING: DOS-compatible mode is deprecated. It's strongly recommended toswitch off the mode (command 'c') and change display units tosectors (command 'u').Command (m for help): #这里输入m或者help进入帮助界面
进入到此界面我们可以输入m或者help来获取使用帮助
Command (m for help): m Command actiona toggle a bootable flag b edit bsd disklabelc toggle the dos compatibility flagd delete a partition #输入d删除分区 l list known partition types #输入l列出内核支持的分区类型ID m print this menun add a new partition #输入n新建分区o create a new empty DOS partition tablep print the partition table #输入p列出当前分区信息 q quit without saving changes #输入q不保存退出 s create a new empty Sun disklabelt change a partition's system id #输入t调整分区类型IDu change display/entry unitsv verify the partition tablew write table to disk and exit #输入w保存退出x extra functionality (experts only)
创建一个主分区
Command (m for help): Disk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0xd0807ba8Device Boot Start End Blocks Id System #当前无分区 Command (m for help): n Command actione extended p primary partition (1-4) ) p #选择创建主分区 Partition number (1-4): 1 First cylinder (1-1305, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): 200 Command (m for help): p Disk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0xd0807ba8Device Boot Start End Blocks Id System /dev/xvdb 83 Linux
创建一个扩展分区
Command (m for help): n Command actione extendedp primary partition (1-4) e Partition number (1-4): 2 First cylinder (201-1305, default 201): Using default value 201 Last cylinder, +cylinders or +size{K,M,G} (201-1305, default 1305): +3G Command (m for help): pDisk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0xd0807ba8Device Boot Start End Blocks Id System /dev/xvdb1 1 200 1606468+ 83 Linux /dev/xvdb2 201 593 3156772+ 5 Extended
创建一个逻辑分区
Command (m for help): pDisk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0x5855c29eDevice Boot Start End Blocks Id System /dev/xvdb1 1 200 1606468+ 83 Linux /dev/xvdb2 201 593 3156772+ 5 ExtendedCommand (m for help): n Command actionl logical (5 or over) #逻辑分区p primary partition (1-4) l First cylinder (201-593, default 201): Using default value 201 Last cylinder, +cylinders or +size{K,M,G} (201-593, default 593): +1G Command (m for help): pDisk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0x5855c29eDevice Boot Start End Blocks Id System /dev/xvdb1 1 200 1606468+ 83 Linux /dev/xvdb2 201 593 3156772+ 5 Extended /dev/xvdb5 1060258+ 83 Linux
调整指定分区的分区类型
Command (m for help): pDisk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0xcd0ac78cDevice Boot Start End Blocks Id System /dev/xvdb1 1 200 1606468+ 83 Linux /dev/xvdb2 201 593 3156772+ 5 ExtendedCommand (m for help): l 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 39 Plan 9 So c1 DRDOS/sec (FAT-2 XENIX root 3c PartitionMagic c4 DRDOS/sec (FAT-3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-4 FAT16 <32M 41 PPC PReP Boot 85 c7 Syrinx 5 Extended 42 SFS 86 NTFS volume set da Non-FS data 6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility 8 AIX 4f QNX4.x 3rd part 8e df BootIt 9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/ 10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b 11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor 14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary 16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS 17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd 1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT 1e Hidden W95 FAT1Command (m for help): t Partition number (1-5): 1 Hex code (type L to list codes): 8e #选择分区类型ID Changed system type of partition 1 to 8e (Linux LVM)Command (m for help): pDisk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0xcd0ac78cDevice Boot Start End Blocks Id System /dev/xvdb1 1 200 1606468+ /dev/xvdb2 201 593 3156772+ 5 Extended
删除指定分区
Command (m for help): d Partition number (1-5): 2 Command (m for help): pDisk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0xcd0ac78cDevice Boot Start End Blocks Id System /dev/xvdb1 1 200 1606468+ 8e Linux LVMCommand (m for help):
分区完成后查看目前目前机器磁盘分区情况
[root@VM_168_102_centos ~]# cat major minor #blocks name202 0 8388608 xvda202 1 8385898 xvda1202 16 10485760 xvdb 202 21 1060258202 32 2097152 xvdc
#mke2fs命令:格式化(配置文件:/etc/mke2fs.conf)
[root@VM_168_102_centos ~]# mke2fs /dev/xvdb1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe style="color: #000000"> blocks 100464 inodes, 401617 blocks 20080 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=415236096 13 block groups 32768 blocks per group, 32768 fragments per group 7728 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912Writing inode tables: done Writing superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 26 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
#blkid命令:查看设备属性,UUID和TYPE
[root@VM_168_102_centos ~]# blkid /dev/xvdb1 /dev/xvdb1: UUID="8f74e3ce-552f-4d1f-a88f-2c7ef02b25cc" TYPE=""
mke2fs –t 指定文件系统类型,如ext2,ext3,ext4
[root@VM_168_102_centos ~]# mke2fs -t /dev/xvdb1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe style="color: #000000"> blocks 100464 inodes, 401617 blocks 20080 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=415236096 13 block groups 32768 blocks per group, 32768 fragments per group 7728 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 36 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@VM_168_102_centos ~]# blkid /dev/xvdb1 /dev/xvdb1: UUID="84af93e0-0047-4ad4-9982-31bddda925c1" TYPE=""
mke2fs –L 设置文件系统卷标
[root@VM_168_102_centos ~]# mke2fs -t ext4 -L /dev/xvdb1 mke2fs 1.41.12 (17-May-2010) Filesystem label=
mke2fs –b 指定块大小,如1024、2048、4096单位字节
[root@VM_168_102_centos ~]# mke2fs -t ext4 -L wanghan -b /dev/xvdb1 mke2fs 1.41.12 (17-May-2010) warning: 418 blocks unused.Filesystem label=wanghan OS type: Linux Block size= (log=1) Fragment size=2048 (log=1) Stride=0 blocks, Stripe style="color: #000000"> blocks 100744 inodes, 802816 blocks 40161 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=537919488 49 block groups 16384 blocks per group, 16384 fragments per group 2056 inodes per group Superblock backups stored on blocks: 16384, 49152, 81920, 114688, 147456, 409600, 442368Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 25 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
mke2fs –m 设置预留管理员的空间百分比
[root@VM_168_102_centos ~]# mke2fs -t ext4 -L wanghan -b 2048 -m /dev/xvdb1 mke2fs 1.41.12 (17-May-2010) warning: 418 blocks unused.Filesystem label=wanghan OS type: Linux Block size=2048 (log=1) Fragment size=2048 (log=1) Stride=0 blocks, Stripe style="color: #000000"> blocks 100744 inodes, 802816 blocks 24097 blocks () reserved for the super user First data block=0 Maximum filesystem blocks=537919488 49 block groups 16384 blocks per group, 16384 fragments per group 2056 inodes per group Superblock backups stored on blocks: 16384, 49152, 81920, 114688, 147456, 409600, 442368Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 35 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
#e2label 查看卷标
[root@VM_168_102_centos ~]# e2label /dev/xvdb1 wanghan
更改卷标
[root@VM_168_102_centos ~]# e2label /dev/xvdb1 [root@VM_168_102_centos ~]# e2label /dev/xvdb1
#dumpe2fs命令:显示当前的磁盘状态 (dumpe2fs –h 仅查看超级快中保存的信息)
[root@VM_168_102_centos ~]# dumpe2fs /dev/xvdb1 dumpe2fs 1.41.12 (17-May-2010) Filesystem volume name: test Last mounted on: <not available> Filesystem UUID: f071494a-55da-4fe1-a93e-6627d69f085f Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize Filesystem flags: signed_directory_hash Default mount options: (none) Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 100744 Block count: 802816 Reserved block count: 24097 Free blocks: 769619 Free inodes: 100733 First block: 0 Block size: 2048 Fragment size: 2048 Reserved GDT blocks: 512 Blocks per group: 16384 Fragments per group: 16384 Inodes per group: 2056 Inode blocks per group: 257 Flex block group size: 16 Filesystem created: Thu Aug 21 17:05:26 2014 Last mount time: n/a Last write time: Thu Aug 21 17:15:55 2014 Mount count: 0 Maximum mount count: 35 Last checked: Thu Aug 21 17:05:26 2014 Check interval: 15552000 (6 months) Next check after: Tue Feb 17 17:05:26 2015 Lifetime writes: 58 MB Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 256 Required extra isize: 28 Desired extra isize: 28 Journal inode: 8 Default directory hash: half_md4 Directory Hash Seed: da63c13e-d2d3-450b-ba50-5bc62847a2cc Journal backup: inode blocks Journal features: (none) Journal size: 32M Journal length: 16384 Journal sequence: 0x00000001 Journal start: 0Group 0: (Blocks 0-16383) [ITABLE_ZEROED]Checksum 0xbddb, unused inodes 2045Primary superblock at 0, Group descriptors at 1-1Reserved GDT blocks at 2-513Block bitmap at 514 (+514), Inode bitmap at 530 (+530)Inode table at 546-802 (+546)11716 free blocks, 2045 free inodes, 2 directories, 2045 unused inodesFree blocks: 4668-16383Free inodes: 12-2056
后面省略
#tune2fs命令:调整查看文件系统参数
tune2fs –l 查看超级块中的信息;与dumpe2fs –h 命令一样
tune2fs –L 更改卷标
[root@VM_168_102_centos ~]# e2label /dev/xvdb1[root@VM_168_102_centos ~]# tune2fs -L /dev/xvdb1 tune2fs 1.41.12 (17-May-2010) [root@VM_168_102_centos ~]# e2label /dev/xvdb1
tune2fs –m 更改预留管理员的空间百分比
[root@VM_168_102_centos ~]# tune2fs -m /dev/xvdb1 tune2fs 1.41.12 (17-May-2010) Setting reserved blocks percentage to (48168 blocks)
#fsck命令:磁盘修复
fsck –a 自动修复错误
[root@VM_168_102_centos ~]# fsck -a /dev/xvda1 fsck from util-linux-ng 2.17.2 /dev/xvda1 is mounted. WARNING!!! The filesystem is mounted. If you continue you ***WILL*** cause ***SEVERE*** filesystem damage.Do you really want to continue (y/n)? yes/dev/xvda1 contains a file system with errors, check forced. /dev/xvda1: Inode 273382, i_blocks is 3104, should be 3096. FIXED. /dev/xvda1: Inode 273383 has illegal block(s). /dev/xvda1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.(i.e., without -a or -p options)
fsck –r 交互式修复错误
[root@VM_168_102_centos ~]# fsck -r /dev/xvda1 fsck from util-linux-ng 2.17.2 e2fsck 1.41.12 (17-May-2010) /dev/xvda1 is mounted. WARNING!!! The filesystem is mounted. If you continue you ***WILL*** cause ***SEVERE*** filesystem damage.Do you really want to continue (y/n)? yes/dev/xvda1 contains a file system with errors, check forced. Pass 1: Checking inodes, blocks, and sizes Inode 273382, i_blocks is 3104, should be 3096. Fix<y>? yesInode 273383 has illegal block(s). Clear<y>? yesIllegal block #12 (2553887680) in inode 273383. CLEARED. Illegal block #13 (16777216) in inode 273383. CLEARED. Illegal block #14 (1601307648) in inode 273383. CLEARED. Illegal block #15 (1887441664) in inode 273383. CLEARED. Illegal block #21 (41950464) in inode 273383. CLEARED. Illegal block #22 (167772160) in inode 273383. CLEARED. Inode 273383, i_blocks is 8192, should be 104. Fix<y>? yesInode 273350 has illegal block(s). Clear<y>? yes
#后面省略
e2fsck –f 强制检测
e2fsck –y 对问题自动回答为YES
#mount命令:挂载命令
mount [options] [-t fstype] [–o options] 设备 挂在点
[options]:命令选项
[-o options]:挂在时启用分区特性
显示当前系统所有已挂载设备信息:
[root@VM_168_102_centos ~]# mount /dev/xvda1 on / type ext3 (rw,noatime,acl,user_xattr) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,mode=0620,gid=5) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
挂载分区:
[root@VM_168_102_centos tmp]# mount [root@VM_168_102_centos tmp]# mount /dev/xvda1 on / type ext3 (rw,noatime,acl,user_xattr) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,mode=0620,gid=5) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
mount –a 自动挂载所有支持自动挂载的设备(/etc/fstab文件中)
[root@VM_168_102_centos ~]# mount /dev/xvda1 on / type ext3 (rw,noatime,acl,user_xattr) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,mode=0620,gid=5) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) [root@VM_168_102_centos ~]# cat /etc/fstab /dev/xvda1 / ext3 noatime,acl,user_xattr 1 1 LABEL=lswap 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 devpts /dev/pts devpts mode=0620,gid=5 0 0 [root@VM_168_102_centos ~]# [root@VM_168_102_centos ~]# mount /dev/xvda1 on / type ext3 (rw,noatime,acl,user_xattr) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,mode=0620,gid=5) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
umount命令:卸载文件系统
[root@VM_168_102_centos ~]# mount /dev/xvda1 on / type ext3 (rw,noatime,acl,user_xattr) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,mode=0620,gid=5) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) [root@VM_168_102_centos ~]# [root@VM_168_102_centos ~]# mount /dev/xvda1 on / type ext3 (rw,noatime,acl,user_xattr) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,mode=0620,gid=5) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
开机自动挂载:
将需要挂载文件系统写入/etc/fstab文件系统挂载表中
[root@VM_168_102_centos tmp]# vim /etc/fstab/dev/xvda1 / ext3 noatime,acl,user_xattr 1 1 LABEL=lswap 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 devpts /dev/pts devpts mode=0620,gid=5 0 0 /dev/xvdb1 /tmp/wanghan ext4 defaults 0 0
#要挂载的设备 #挂载点,swap挂载点为swap #文件系统类型 #挂载选项 #是否备份(0:从不备份;1每日备份) #自检次序(0:不自检
#fuser命令:查询给定文件或目录的用户或进程信息
[root@VM_168_102_centos ~]# fuser /tmp/wanghan /tmp/wanghan: 26452c
fuser –v 显示更详细信息
[root@VM_168_102_centos ~]# fuser -v /tmp/wanghanUSER PID ACCESS COMMAND /tmp/wanghan: wanghan 26452 ..c.. bash
fuser –km 关闭占用进程
[root@VM_168_102_centos ~]# fuser -v /tmp/wanghanUSER PID ACCESS COMMAND /tmp/wanghan: wanghan 26452 ..c.. bash [root@VM_168_102_centos ~]# fuser -km /tmp/wanghan /tmp/wanghan: 26452c [root@VM_168_102_centos ~]# fuser -v /tmp/wanghan
#df命令:显示磁盘空间的使用信息
[root@VM_168_102_centos ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda1 8254240 1216828 6618120 16% / [root@VM_168_102_centos ~]# mount /dev/xvdb1 /tmp/wanghan [root@VM_168_102_centos ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda1 8254240 1216832 6618116 16% / /dev/xvdb1 2071384 68632 1897528 4% /tmp/wanghan
df –h 方便阅读方式显示
[root@VM_168_102_centos ~]# df -h /dev/xvdb1 Filesystem Size Used Avail Use% Mounted on /dev/xvdb1 2.0G 68M 1.9G 4% /tmp/wanghan
df –i 显示inode信息
Filesystem Inodes IUsed IFree IUse% Mounted on /dev/xvda1 512K 33K 480K 7% / /dev/xvdb1 129K 11 129K 1% /tmp/wanghan
#du命令:显示每个文件和目录的磁盘使用空间
[root@VM_168_102_centos tmp]# du 16 ./wanghan/lost+found 20 ./wanghan 4 ./.ICE-unix 32 .
[root@VM_168_102_centos tmp]# du /tmp 16 /tmp/wanghan/lost+found 20 /tmp/wanghan 4 /tmp/.ICE-unix 32 /tmp
du –h:方便阅读方式显示
[root@VM_168_102_centos tmp]# du -h 16K ./wanghan/lost+found 20K ./wanghan 4.0K ./.ICE-unix 32K .
du -s:显示总计,仅列出最后相加的总值
[root@VM_168_102_centos tmp]# du -s -h 32K .
#查看内存空间使用状态
查看 /proc/meminfo文件
[root@VM_168_102_centos tmp]# cat /proc/meminfo MemTotal: 1018532 kB MemFree: 785884 kB Buffers: 43724 kB Cached: 116488 kB SwapCached: 0 kB Active: 67776 kB Inactive: 107592 kB Active(anon): 15268 kB Inactive(anon): 2604 kB Active(file): 52508 kB Inactive(file): 104988 kB Unevictable: 0 kB Mlocked: 0 kB0 kB0 kB Dirty: 120 kB Writeback: 0 kB AnonPages: 15160 kB Mapped: 12424 kB Shmem: 2728 kB Slab: 41732 kB SReclaimable: 21500 kB SUnreclaim: 20232 kB KernelStack: 656 kB PageTables: 1664 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 509264 kB Committed_AS: 86312 kB VmallocTotal: 34359738367 kB VmallocUsed: 7212 kB VmallocChunk: 34359729020 kB HardwareCorrupted: 0 kB AnonHugePages: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 6144 kB DirectMap2M: 1042432 kB
#free命令:监控 Linux 内存使用状况
[root@VM_168_102_centos tmp]# freetotal used free shared buffers cached Mem: 1018532 235012 783520 0 44368 116564 -/+ buffers/cache: 74080 944452 Swap: 2097144 0 2097144
free –m 显示结果以MB为单位
free –g 显示结果以GB为单位
#dd命令:把指定的输入文件拷贝到指定的输出文件中,并且在拷贝的过程中可以进行格式转换
dd if=input_file of=output_file bs=#[b|k|m|g] count=#
[root@VM_168_102_centos tmp]# dd if=/tmp/test.sh of=/tmp/ceshi.sh 0+1 records in 0+1 records out 153 bytes (153 B) copied, 3.3824e-05 s, 4.5 MB/s [root@VM_168_102_centos tmp]# cat ceshi.sh sssssssssssssssssssssssssssssssssssssssssssssssssdsdsdsdsdsdddddddddddddddddddddddddddddddddddbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccbbbbbbb[root@VM_168_102_centos tmp]# cat test.sh sssssssssssssssssssssssssssssssssssssssssssssssssdsdsdsdsdsdddddddddddddddddddddddddddddddddddbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccbbbbbbb
备份MBR并进行恢复
[root@VM_168_102_centos tmp]# fdisk -l /dev/xvdbDisk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0xd30f2acfDevice Boot Start End Blocks Id System [root@VM_168_102_centos tmp]# dd if=/dev/xvdb of=/tmp/xvdb bs=512 count=1 1+0 records in 1+0 records out 512 bytes (512 B) copied, 0.00227598 s, 225 kB/s [root@VM_168_102_centos tmp]# dd if=/dev/zero of=/dev/xvdb bs=512 count=1 1+0 records in 1+0 records out 512 bytes (512 B) copied, 0.000697809 s, 734 kB/s [root@VM_168_102_centos tmp]# fdisk -l /dev/xvdbDisk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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[root@VM_168_102_centos tmp]# dd if=/tmp/xvdb of=/dev/xvdb
1+0 records in 1+0 records out 512 bytes (512 B) copied, 0.000623246 s, 822 kB/s [root@VM_168_102_centos tmp]# fdisk -l /dev/xvdbDisk /dev/xvdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 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: 0xd30f2acf/dev/xvdb6 656 787 1060258+ 83 Linux
转载于:https://blog.51cto.com/putongren/1543020
linux学习命令总结⑩②相关推荐
- Linux学习命令总结个人及个人心得
在开始今天的讲课,我们还是一如既往的回顾下前面我们讲解的内容.前面我讲解了Linux的12类命令,及三剑客与正则表达式.他是我们学会Linux的基础,大家一定要下功夫把他们掌握了,今天我们说下Linu ...
- Linux学习命令汇总三——Linux用户组管理,文件权限管理,文本搜索命令grep及正则表达式...
本章Blog相关Linux知识点 解析:在数据库按搜索码查找相对应的条目,并找与之对应额外的其他数据库的过程:名称解析:UID ,组名解析:GID 数据库:文本文件,sql数据库,ldap数据库,用户 ...
- Linux学习 命令部分
一:目录结构 Bin: 全称binary,含义是二进制.文件都是可运行的. Dev:该目录中主要存放的是外接设备,例如U盘,移动硬盘,光盘.在其中的外接设备是不能直接被使用的,需要挂载(类似于Wind ...
- 生信宝典Linux学习系列文章整理
欢迎关注天下博客:http://blog.genesino.com/2017/10/sxbd-linux-summary/ 生信宝典推出的Linux从入门到常用命令.软件安装方法.数据处理方法都在这了 ...
- linux系统管理学习笔记之一-------linux解压缩命令
linux系统管理学习笔记之一-------linux解压缩命令 2009-12-29 11:52:55 标签:linux tar [推送到技术圈] 版权声明:原创作品,允许转载,转载时请务必以超链接 ...
- linux rcs文件中的ip,linux学习笔记之diff和patch命令
关键字:Linux 学习笔记 运维 系统 命令 一.命令的功能 diff命令的功能为逐行比较两个文本文件,列出其不同之处.可是做成diff记录也就是补丁. patch就是利用diff制作的补丁来打到文 ...
- Linux学习之命令【1】
Linux学习之命令[1] 一·命令总览 1.基本简单命令 1.0 pwd 1.1 echo 1.2 date 1.3 cal 1. ...
- Linux 学习笔记之超详细基础linux命令 Part 3
Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 2----------------- ...
- Linux学习笔记(二)|常用命令
Linux学习笔记(二)常用命令 1.文件处理命令 1.1命令格式与目录处理 -ls 功能描述:显示目录文件 原意:list 所在路径:/bin/ls 语法: ls-a 显示所有文件,包括隐藏文件 l ...
最新文章
- 微软:Azure AI是OpenAI技术商业化变现唯一、排他性合作方
- MySQL管理与优化(20):MySQL日志
- Getting Started with OpenCV
- Android 强烈推荐:程序员接私活那点事
- VTK:PolyData之BooleanOperationPolyDataFilter
- mvc 一般注释_使用带有注释和JQuery的Spring MVC 3的Ajax
- 用PyTorch创建一个图像分类器?So easy!(Part 1)
- node.js 端口号被占用解决方法
- python-kafka多线程快速读取consumer消费者数据,同时使用批读取与无限流读取改进
- 知乎要用AI打造智能社区,专治「答非所问」的瓦力机器人已上线
- 计算机断电后黑屏怎么办,电脑断电黑屏怎么办
- inode客户端 linux,Ubuntu 11.10 H3C iNode 客户端下载及安装图解
- 赋能未来的昆腾全新Scalar存储平台
- 数据一致性(CAP原则)
- 处理行内元素行内块元素中间空隙
- iText API操作doc文档
- 《做出好决定》当下决定将严重影响你未来的决定
- 经常听到卡农吧,可是你知道卡农背后的含义么?
- 人类一败涂地做图教程_人类一败涂地-怎么制作地图-地图制作教程详细入门级...
- 最长黑白相间连续串(有规律)