请教上海linux学习价格求老司机讲解!

linux学习命令总结⑩②
针对某一个挂载设别查看:
[root@VM_168_102_centos ~]# fdisk -l /dev/xvda
Disk /dev/xvda: 8589 MB,
#该设备空间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: 0x
Device#分区序列 Boot#引导 Start#开始柱面 End#结束柱面 Blocks#容量
Id#分区类型ID
System#分区类型
/dev/xvda1
通过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 to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): #这里输入m或者help进入帮助界面
进入到此界面我们可以输入m或者help来获取使用帮助
Command (m for help): m
Command action
toggle a bootable flag
edit bsd disklabel
toggle the dos compatibility flag
delete a partition #输入d删除分区
list known partition types #输入l列出内核支持的分区类型ID
print this menu
add a new partition #输入n新建分区
create a new empty DOS partition table
print the partition table #输入p列出当前分区信息
quit without saving changes #输入q不保存退出
create a new empty Sun disklabel
change a partition's system id #输入t调整分区类型ID
change display/entry units
verify the partition table
write table to disk and exit #输入w保存退出
extra functionality (experts only)
创建一个主分区
Command (m for help): p #列出当前分区信息
Disk /dev/xvdb: 10.7 GB,
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: 0xd0807ba8
Device Boot
#当前无分区
Command (m for help): n #新建分区
Command action
extended #扩展分区(无法格式化)
primary partition (1-4) #主分区(最多四个)
p #选择创建主分区
Partition number (1-4): 1 #创建第一个主分区
First cylinder (1-1305, default 1): #起始柱面(始终由1开始)
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): 200 #结束柱面(每个柱面大小约8.22M,再乘以起始柱面到结束柱面的个数就等于该分区的大小;也可以自定大小如输入+1000M/+1G)
Command (m for help): p #列出当前分区信息
Disk /dev/xvdb: 10.7 GB,
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: 0xd0807ba8
Device Boot
/dev/xvdb1
创建一个扩展分区
Command (m for help): n
Command action
primary partition (1-4)
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): +<span style="color: #G
Command (m for help): p
Disk /dev/xvdb: 10.7 GB,
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: 0xd0807ba8
Device Boot
/dev/xvdb1
/dev/xvdb2
创建一个逻辑分区
Command (m for help): p
Disk /dev/xvdb: 10.7 GB,
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: 0x5855c29e
Device Boot
/dev/xvdb1
/dev/xvdb2
Command (m for help): n
Command action
logical (5 or over) #逻辑分区
primary partition (1-4)
First cylinder (201-593, default 201):
Using default value 201
Last cylinder, +cylinders or +size{K,M,G} (201-593, default 593): +<span style="color: #G #输入大小不可超过扩展分区的总容量
Command (m for help): p
Disk /dev/xvdb: 10.7 GB,
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: 0x5855c29e
Device Boot
/dev/xvdb1
/dev/xvdb2
/dev/xvdb5
调整指定分区的分区类型
Command (m for help): p
Disk /dev/xvdb: 10.7 GB,
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: 0xcd0ac78c
Device Boot
/dev/xvdb1
/dev/xvdb2
Command (m for help): l #列出内核内支持的分区类型ID
Minix / old Lin bf
Linux swap / So c1
DRDOS/sec (FAT-
XENIX root
PartitionMagic
DRDOS/sec (FAT-
Venix 80286
OS/2 hidden C:
DRDOS/sec (FAT-
FAT16 &32M
PPC PReP Boot
Linux extended
NTFS volume set da
Non-FS data
NTFS volume set db
CP/M / CTOS / .
QNX4.x 2nd part 88
Linux plaintext de
Dell Utility
QNX4.x 3rd part 8e
AIX bootable
OnTrack DM
DOS access
OS/2 Boot Manag 51
OnTrack DM6 Aux 94
Amoeba BBT
W95 FAT32 (LBA) 53
OnTrack DM6 Aux a0
IBM Thinkpad hi eb
W95 FAT16 (LBA) 54
OnTrackDM6
W95 Ext'd (LBA) 55
EFI (FAT-12/16/
Golden Bow
Linux/PA-RISC b
Hidden FAT12
Priam Edisk
Darwin UFS
Compaq diagnost 61
Hidden FAT16 &3 63
GNU HURD or Sys ab
Darwin boot
DOS secondary
Hidden FAT16
Novell Netware
HFS / HFS+
VMware VMFS
Hidden HPFS/NTF 65
Novell Netware
VMware VMKCORE
AST SmartSleep
DiskSecure Mult b8
Linux raid auto
Hidden W95 FAT3 75
Boot Wizard hid fe
Hidden W95 FAT3 80
Solaris boot
Hidden W95 FAT1
Command (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): p
Disk /dev/xvdb: 10.7 GB,
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: 0xcd0ac78c
Device Boot
/dev/xvdb1
/dev/xvdb2
删除指定分区
Command (m for help): d #删除分区
Partition number (1-5): 2 #输入要删除的分区序列
Command (m for help): p
Disk /dev/xvdb: 10.7 GB,
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: 0xcd0ac78c
Device Boot
/dev/xvdb1
Command (m for help):
分区完成后查看目前目前机器磁盘分区情况
[root@VM_168_102_centos ~]# cat /proc/partitions
major minor
8388608 xvda
8385898 xvda1
1606468 xvdb1
1060258 xvdb5
2097152 xvdc
#mke2fs命令:格式化(配置文件:/etc/mke2fs.conf)
[root@VM_168_102_centos ~]# mke2fs /dev/xvdb1 #把该设备格式化成ext2文件系统
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 #预留管理员空间的百分比,默认百分5%
First data block=0
Maximum filesystem blocks=
13 block groups
32768 blocks per group, 32768 fragments per group
7728 inodes per group
Superblock backups stored on blocks:
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This 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=&ext2&
mke2fs –t 指定文件系统类型,如ext2,ext3,ext4
[root@VM_168_102_centos ~]# mke2fs -t ext4 /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=
13 block groups
32768 blocks per group, 32768 fragments per group
7728 inodes per group
Superblock backups stored on blocks:
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This 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--9982-31bddda925c1& TYPE=&ext4&
mke2fs –L 设置文件系统卷标
[root@VM_168_102_centos ~]# mke2fs -t ext4 -L wanghan /dev/xvdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=wanghan
mke2fs –b 指定块大小,如、4096单位字节
[root@VM_168_102_centos ~]# mke2fs -t ext4 -L wanghan -b 2048 /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
40161 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=
49 block groups #调整了块大小,块组数量随之变化
16384 blocks per group, 16384 fragments per group
2056 inodes per group
Superblock backups stored on blocks:
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This 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 3 /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 (3.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=
49 block groups
16384 blocks per group, 16384 fragments per group
2056 inodes per group
Superblock backups stored on blocks:
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This 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
[root@VM_168_102_centos ~]# e2label /dev/xvdb1 test
[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:
Last mounted on:
&not available&
Filesystem UUID:
f071494a-55da-4fe1-a93e-<span style="color: #27d69f085f
Filesystem magic number:
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:
Filesystem state:
Errors behavior:
Filesystem OS type:
Inode count:
Block count:
Reserved block count:
Free blocks:
Free inodes:
First block:
Block size:
Fragment size:
Reserved GDT blocks:
Blocks per group:
Fragments per group:
Inodes per group:
Inode blocks per group:
Flex block group size:
Filesystem created:
Thu Aug 21 17:05:26 2014
Last mount time:
Last write time:
Thu Aug 21 17:15:55 2014
Mount count:
Maximum mount count:
Last checked:
Thu Aug 21 17:05:26 2014
Check interval:
Next check after:
Tue Feb 17 17:05:26 2015
Lifetime writes:
Reserved blocks uid:
0 (user root)
Reserved blocks gid:
0 (group root)
First inode:
Inode size:
Required extra isize:
Desired extra isize:
Journal inode:
Default directory hash:
Directory Hash Seed:
da63c13e-d2d3-450b-ba50-<span style="color: #bc62847a2cc
Journal backup:
inode blocks
Journal features:
Journal size:
Journal length:
Journal sequence:
Journal start:
Group 0: (Blocks 0-16383) [ITABLE_ZEROED]
Checksum 0xbddb, unused inodes 2045
Primary superblock at 0, Group descriptors at 1-1
Reserved GDT blocks at 2-513
Block 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 inodes
Free blocks:
Free 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 wanghan /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 6 /dev/xvdb1
tune2fs 1.41.12 (17-May-2010)
Setting reserved blocks percentage to 6% (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.
/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&? yes
Inode 273383 has illegal block(s).
Clear&y&? yes
Illegal block #12 () in inode 273383.
Illegal block #13 () in inode 273383.
Illegal block #14 () in inode 273383.
Illegal block #15 () in inode 273383.
Illegal block #21 () in inode 273383.
Illegal block #22 () in inode 273383.
Inode 273383, i_blocks is 8192, should be 104.
Fix&y&? yes
Inode 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 /dev/xvdb1 /tmp/wanghan
[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)
/dev/xvdb1 on /tmp/wanghan type ext4 (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
noatime,acl,user_xattr 1 1
LABEL=lswap
defaults 0 0
/sys/kernel/debug
mode=0620,gid=5
/dev/xvdb1
/tmp/wanghan
[root@VM_168_102_centos ~]# mount -a
[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)
/dev/xvdb1 on /tmp/wanghan type ext4 (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)
/dev/xvdb1 on /tmp/wanghan type ext4 (rw)
[root@VM_168_102_centos ~]# umount /dev/xvdb1 #也可以输入挂载点进行指定卸载
[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
noatime,acl,user_xattr 1 1
LABEL=lswap
defaults 0 0
/sys/kernel/debug
mode=0620,gid=5
/dev/xvdb1
/tmp/wanghan
#要挂载的设备&&&&&&&&&&&&& & #挂载点,swap挂载点为swap&&& #文件系统类型&&&&& #挂载选项&&&&&&&&&&&&&&&&&&&&& #是否备份(0:从不备份;1每日备份)&&&&&&& #自检次序(0:不自检
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 1或者2为要自检,如果是根分区要设为1,
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 其他分区只能是2)
#fuser命令:查询给定文件或目录的用户或进程信息
[root@VM_168_102_centos ~]# fuser /tmp/wanghan
/tmp/wanghan:
fuser –v 显示更详细信息
[root@VM_168_102_centos ~]# fuser -v /tmp/wanghan
PID ACCESS COMMAND
/tmp/wanghan:
26452 ..c.. bash
fuser –km 关闭占用进程
[root@VM_168_102_centos ~]# fuser -v /tmp/wanghan
PID ACCESS COMMAND
/tmp/wanghan:
26452 ..c.. bash
[root@VM_168_102_centos ~]# fuser -km /tmp/wanghan
/tmp/wanghan:
[root@VM_168_102_centos ~]# fuser -v /tmp/wanghan
#df命令:显示磁盘空间的使用信息
[root@VM_168_102_centos ~]# df
Filesystem
Used Available Use% Mounted on
/dev/xvda1
[root@VM_168_102_centos ~]# mount /dev/xvdb1 /tmp/wanghan
[root@VM_168_102_centos ~]# df
Filesystem
Used Available Use% Mounted on
/dev/xvda1
/dev/xvdb1
4% /tmp/wanghan
df –h 方便阅读方式显示
[root@VM_168_102_centos ~]# df -h /dev/xvdb1
Filesystem
Used Avail Use% Mounted on
/dev/xvdb1
4% /tmp/wanghan
df –i 显示inode信息
Filesystem
IFree IUse% Mounted on
/dev/xvda1
/dev/xvdb1
1% /tmp/wanghan
#du命令:显示每个文件和目录的磁盘使用空间
[root@VM_168_102_centos tmp]# du #显示当前所在目录的每个文件的磁盘使用空间
./wanghan/lost+found
./.ICE-unix
[root@VM_168_102_centos tmp]# du /tmp #指定查看
/tmp/wanghan/lost+found
/tmp/wanghan
/tmp/.ICE-unix
du –h:方便阅读方式显示
[root@VM_168_102_centos tmp]# du -h
./wanghan/lost+found
./.ICE-unix
du -s:显示总计,仅列出最后相加的总值
[root@VM_168_102_centos tmp]# du -s -h
#查看内存空间使用状态
查看 /proc/meminfo文件
[root@VM_168_102_centos tmp]# cat /proc/meminfo
1018532 kB
SwapCached:
Active(anon):
Inactive(anon):
Active(file):
Inactive(file):
Unevictable:
SwapTotal:
Writeback:
AnonPages:
SReclaimable:
SUnreclaim:
KernelStack:
PageTables:
NFS_Unstable:
WritebackTmp:
CommitLimit:
Committed_AS:
VmallocTotal:
VmallocUsed:
VmallocChunk:
HardwareCorrupted:
AnonHugePages:
HugePages_Total:
HugePages_Free:
HugePages_Rsvd:
HugePages_Surp:
Hugepagesize:
DirectMap4k:
DirectMap2M:
1042432 kB
#free命令:监控 Linux 内存使用状况
[root@VM_168_102_centos tmp]# free
-/+ buffers/cache:
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/xvdb
Disk /dev/xvdb: 10.7 GB,
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
Device Boot
/dev/xvdb1
/dev/xvdb2
/dev/xvdb5
/dev/xvdb6
[root@VM_168_102_centos tmp]# dd if=/dev/xvdb of=/tmp/xvdb bs=512 count=1 #将512Byte大小的MBR备份到/tmp/xvdb
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0. 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. s, 734 kB/s
[root@VM_168_102_centos tmp]# fdisk -l /dev/xvdb
Disk /dev/xvdb: 10.7 GB,
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: 0x
[root@VM_168_102_centos tmp]# dd if=/tmp/xvdb of=/dev/xvdb #将备份到/tmp/xvdb的MBR信息重新写入
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0. s, 822 kB/s
[root@VM_168_102_centos tmp]# fdisk -l /dev/xvdb
Disk /dev/xvdb: 10.7 GB,
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
Device Boot
/dev/xvdb1
/dev/xvdb2
/dev/xvdb5
/dev/xvdb6
<span type="1" blog_id="1543020" userid='
分享到朋友圈
好的文章,和好友一起分享

我要回帖

 

随机推荐