liunx命令5 df、du、fdisk、磁盘管理相关命令

df查看命令

[[email protected] ~]# df              //查看分区

Filesystem     1K-blocks    Used Available Use% Mounted on

/dev/sda3       18244476 5919104  11391948  35% /

tmpfs             515244      72    515172   1% /dev/shm

/dev/sda1         194241   26001    158000  15% /boot

[[email protected] ~]# free            //查看swap使用情况

total       used       free     shared    buffers     cached

Mem:       1030492     419328     611164       1348      66492     194216

-/+ buffers/cache:     158620     871872

Swap:      2097148          0    2097148

[[email protected] ~]# df -h                     //已合适单位显示

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        18G  5.7G   11G  35% /

tmpfs           504M   72K  504M   1% /dev/shm

/dev/sda1       190M   26M  155M  15% /boot

[[email protected] ~]# df -k -m                 //已K、M为单位显示

Filesystem     1M-blocks  Used Available Use% Mounted on

/dev/sda3          17817  5781     11125  35% /

tmpfs                504     1       504   1% /dev/shm

/dev/sda1            190    26       155  15% /boot

[[email protected] ~]# df -i                    //查看inode使用情况

Filesystem      Inodes  IUsed   IFree IUse% Mounted on

/dev/sda3      1166880 160054 1006826   14% /

tmpfs           128811      4  128807    1% /dev/shm

/dev/sda1        51200     38   51162    1% /boot

du 命令

[[email protected] ~]# du /etc/                 //查看文件,大小使用情况

[[email protected] ~]#  du -h /etc/             //已合适大小显示etc使用情况

[[email protected] ~]# du -sh /etc/             //查看/etc/大小使用情况

40M     /etc/

[[email protected] ~]# ls -lh /etc/init.d/iptables

-rwxr-xr-x. 1 root root 11K Oct 15  2014 /etc/init.d/iptables

[[email protected] ~]# du -sh /etc/init.d/iptables

12K     /etc/init.d/iptables

[[email protected] ~]# ls -lb /etc/init.d/iptables                          //已b为单位显示

-rwxr-xr-x. 1 root root 10688 Oct 15  2014 /etc/init.d/iptables

[[email protected] ~]# du -sb /etc/init.d/iptables

10688   /etc/init.d/iptables

查看文件大小的两个命令,两者大小显示不一样

[[email protected] ~]# touch 12

[[email protected] ~]# echo "12">12

[[email protected] ~]# ls -lh 12                       //查看新建文件大小为3b

-rw-r--r--. 1 root root 3 Jul  8 20:24 12

[[email protected] ~]# ls -lb 12

-rw-r--r--. 1 root root 3 Jul  8 20:24 12

[[email protected] ~]# du -sh 12                    //查看该文件大小为4k

4.0K    12

//为什么呢:du命令,查看文件占用磁盘空间大小,(理解为一个磁盘分成一块一块,最小一块为4k,)。ls命令,查看文件本身实际的大小。

fdisk命令

[[email protected] ~]# fdisk -l                     //查看磁盘,分区使用情况

Disk /dev/sda: 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: 0x00052035

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26         287     2097152   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3             287        2611    18668544   83  Linux

[[email protected] ~]# init 0             //关闭虚拟机加一块硬盘(SCSIS)

[[email protected] ~]# fdisk -l            //查看添加的一块硬盘

Disk /dev/sda: 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: 0x00052035

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26         287     2097152   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3             287        2611    18668544   83  Linux

Disk /dev/sdb: 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

[[email protected] ~]# fdisk -l /dev/sda            //查看一块指定的磁盘

Disk /dev/sda: 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: 0x00052035

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26         287     2097152   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3             287        2611    18668544   83  Linux

[[email protected] ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 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

[[email protected] ~]# fdisk /dev/sdb                     //fdisk新磁盘

Command (m for help): p                             //打印当前使用命令

Disk /dev/sdb: 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: 0xcacffefa

Device Boot      Start         End      Blocks   Id  System

Command (m for help): n                       //n新建分区

Command action

e   extended

p   primary partition (1-4)

p                                          //p主分区,e扩展分区

Partition number (1-4): 1

First cylinder (1-1305, default 1): 1

Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): +2G            //给2G大小

Command (m for help): p                      //打印

Disk /dev/sdb: 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: 0xcacffefa

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         262     2104483+  83  Linux

Command (m for help): n                          //n新建分区

Command action

e   extended

p   primary partition (1-4)

e                                             //e扩展分区

Partition number (1-4): 2

First cylinder (263-1305, default 263): 263

Last cylinder, +cylinders or +size{K,M,G} (263-1305, default 1305): +5G

Command (m for help): p

Disk /dev/sdb: 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: 0xcacffefa

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         262     2104483+  83  Linux

/dev/sdb2             263         916     5253255    5  Extended

Command (m for help): l                  //查看分区id

0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris

1  FAT12           39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-

2  XENIX root      3c  PartitionMagic  83  Linux           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  Linux extended  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  Linux LVM       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  Linux raid auto

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 FAT1

Command (m for help): p                     //看分区表

Disk /dev/sdb: 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: 0xcacffefa

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         262     2104483+  83  Linux

/dev/sdb2             263         916     5253255    5  Extended

Command (m for help): n                       //出现l选项,l扩展分区,p主分区

Command action

l   logical (5 or over)

p   primary partition (1-4)

l                                                 //选扩展分区

First cylinder (263-916, default 263): p

First cylinder (263-916, default 263): l

First cylinder (263-916, default 263): 263

Last cylinder, +cylinders or +size{K,M,G} (263-916, default 916): +2G

Command (m for help): p

Disk /dev/sdb: 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: 0xcacffefa

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         262     2104483+  83  Linux

/dev/sdb2             263         916     5253255    5  Extended

/dev/sdb5             263         524     2104483+  83  Linux

Command (m for help): w                                //w保存

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[[email protected] ~]# fdisk -l /dev/sdb                     //查看分区使用情况

Disk /dev/sdb: 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: 0xcacffefa

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         262     2104483+  83  Linux

/dev/sdb2             263         916     5253255    5  Extended

/dev/sdb5             263         524     2104483+  83  Linux

[[email protected] ~]#

磁盘格mke2fs

磁盘分区后,不能马上用,还需格式化成指定格式。

[[email protected] ~]# cat /etc/filesystems              //查看磁盘有哪些格式

ext4

ext3

ext2

nodev proc

nodev devpts

iso9660

vfat

hfs

hfsplus

[[email protected] ~]# mkfs.ext4 /dev/sdb5            //将/dev/sdb5分区格式化成ext4格式

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 width=0 blocks

131648 inodes, 526120 blocks

26306 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=541065216

17 block groups

32768 blocks per group, 32768 fragments per group

7744 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912

Writing inode tables: done

Creating journal (16384 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[[email protected] ~]#  mke2fs -t ext4 -b 1024 -m 1 -L  wangchao  /dev/sdb1

//将/dev/sdb1格式化成ext4格式,-t指定格式,-b指定块大小为1024b.-m保留1%。-L磁盘标签

mke2fs 1.41.12 (17-May-2010)

Filesystem label=wangchao

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks

131584 inodes, 2104480 blocks

21044 blocks (1.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=69468160

257 block groups

8192 blocks per group, 8192 fragments per group

512 inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409, 663553,

1024001, 1990657

Writing inode tables: done

Creating journal (32768 blocks): 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.

//mkfs.ext4、mkfs.ext3与mke2fs命令相似。mke2fs多一些功能

磁盘挂载与卸载

磁盘格式化后,要想写入数据还需挂载上。

[email protected] ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 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: 0xcacffefa

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         262     2104483+  83  Linux

/dev/sdb2             263         916     5253255    5  Extended

/dev/sdb5             263         524     2104483+  83  Linux

[[email protected] ~]# mount /dev/sdb5 /mnt/               //将/dev/sdb5 挂载在/mnt/下

[[email protected] ~]# df -h                         //查看已将/dev/sdb5 挂载在/mnt/下

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        18G  5.7G   11G  35% /

tmpfs           504M   72K  504M   1% /dev/shm

/dev/sda1       190M   26M  155M  15% /boot

/dev/sdb5       2.0G  3.1M  1.9G   1% /mnt

[[email protected] ~]# df -T                             //查看磁盘分区类型

Filesystem     Type  1K-blocks    Used Available Use% Mounted on

/dev/sda3      ext4   18244476 5919796  11391256  35% /

tmpfs          tmpfs    515244      72    515172   1% /dev/shm

/dev/sda1      ext4     194241   26001    158000  15% /boot

/dev/sdb5      ext4    2005848    3096   1897528   1% /mnt

[[email protected] ~]# mkdir /home/wangchao/123

[[email protected] ~]# mount /dev/sdb1 /home/            //挂载后home下文件被覆盖

[[email protected] ~]# umount /home/                   //卸载

[[email protected] ~]# mount LABEL=wangchao /home/wangchao/123/        //使用标签挂载

[[email protected] ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        18G  5.7G   11G  35% /

tmpfs           504M   72K  504M   1% /dev/shm

/dev/sda1       190M   26M  155M  15% /boot

/dev/sdb5       2.0G  3.1M  1.9G   1% /mnt

/dev/sdb1       2.0G  3.1M  2.0G   1% /home/wangchao/123

[[email protected] ~]# cd /mnt/

[[email protected] mnt]# ls

lost+found

[[email protected] mnt]# touch 123

[[email protected] mnt]# umount /mnt/                         //在目录里卸载回失败

umount: /mnt: device is busy.

(In some cases useful info about processes that use

the device is found by lsof(8) or fuser(1))

[[email protected] mnt]# cd                                 //先退出才能卸载

[[email protected] 123]#  umount /dev/sdb1

umount: /home/wangchao/123: device is busy.

(In some cases useful info about processes that use

the device is found by lsof(8) or fuser(1))

[[email protected] 123]#  umount -l /dev/sdb1          //加参数-l强制卸载,不退出卸载

分区表fstab

以上挂载为手动方式,重启后将失效,自动开机挂载方法如下:

[[email protected] 123]# cat /etc/fstab                  //分区配置文件

#

# /etc/fstab

# Created by anaconda on Mon Jun  8 19:14:01 2015

#

# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

UUID=41e6be85-0f8b-41ec-9559-f48a356d54f0 /                       ext4    defaults        1 1

UUID=ca50ee18-a125-4629-8c11-1b6134912239 /boot                   ext4    defaults        1 2

UUID=e7c33c68-670b-4a2a-b1aa-4ceacf4f0e86 swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

[[email protected] 123]# ls /etc/rc.local

/etc/rc.local

//也可将mount写入,开机自动执行。该文件为开机就运行其中的命名

[[email protected] 123]# cat /etc/fstab

#

# /etc/fstab

# Created by anaconda on Mon Jun  8 19:14:01 2015

#

# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

UUID=41e6be85-0f8b-41ec-9559-f48a356d54f0 /                       ext4    defaults        1 1

UUID=ca50ee18-a125-4629-8c11-1b6134912239 /boot                   ext4    defaults        1 2

UUID=e7c33c68-670b-4a2a-b1aa-4ceacf4f0e86 swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

//其中UUID为每个硬盘的标识,每个硬盘唯一。(不止硬盘设备,其他如网卡都有UUID)

[[email protected] 123]# blkid                    //查看硬盘的UUID

/dev/sda1: UUID="ca50ee18-a125-4629-8c11-1b6134912239" TYPE="ext4"

/dev/sda2: UUID="e7c33c68-670b-4a2a-b1aa-4ceacf4f0e86" TYPE="swap"

/dev/sda3: UUID="41e6be85-0f8b-41ec-9559-f48a356d54f0" TYPE="ext4"

/dev/sdb1: LABEL="wangchao" UUID="2be2198d-dcb8-4589-8a34-8b3d472cbece" TYPE="ext4"

/dev/sdb5: UUID="87dba34e-66d1-47b6-a990-9c285b4958db" TYPE="ext4"

[[email protected] 123]# mount UUID="87dba34e-66d1-47b6-a990-9c285b4958db" /mnt/

//将UUID="87dba34e-66d1-47b6-a990-9c285b4958db" 的硬盘挂载到/mnt/下

[[email protected] 123]# df -h                     //查看挂载

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        18G  5.7G   11G  35% /

tmpfs           504M   72K  504M   1% /dev/shm

/dev/sda1       190M   26M  155M  15% /boot

/dev/sdb5       2.0G  3.1M  1.9G   1% /mnt

[[email protected] 123]# vi /etc/fstab

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

/dev/sdb5               /mnt              ext4       defaults          0 0

///dev/sdb5 磁盘 /mnt 挂载点 ext4 格式  defaults  0(是否备份,否) 0开机自检,否

写入文件后生效,下次重启还是有效

[[email protected] 123]# cd

[[email protected] ~]# umount /mnt/

umount: /mnt/: not mounted

[[email protected] ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        18G  5.7G   11G  35% /

tmpfs           504M   72K  504M   1% /dev/shm

[[email protected] ~]# mount -a                      //自动挂载,是写入文件的自动挂载

[[email protected] ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        18G  5.7G   11G  35% /

tmpfs           504M   72K  504M   1% /dev/shm

/dev/sda1       190M   26M  155M  15% /boot

/dev/sdb5       2.0G  3.1M  1.9G   1% /mnt

[[email protected] ~]# vi /etc/rc.local

#!/bin/sh

#

# This script will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don‘t

# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

mount /dev/sdb1 /home/wangchao/123

//下次重启自动执行mount /dev/sdb1 /home/wangchao/123命令

[[email protected] ~]# mount                         //查看磁盘挂载加载了哪些选项

/dev/sda3 on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")

/dev/sda1 on /boot type ext4 (rw)

/dev/sdb5 on /mnt type ext4 (rw)

时间: 2024-10-11 10:24:10

liunx命令5 df、du、fdisk、磁盘管理相关命令的相关文章

Linux学习笔记一 磁盘管理常用命令

Linux学习笔记一 磁盘管理常用命令 Linux系统下,一切均是文件,磁盘是一种特殊的块设备文件. 常用的硬盘接口类型 并口:IDE ,SCSI 串口:SATA,SAS 磁盘设备文件设备文件的命令规则: IDE: 设备名为/dev/hda, /dev/hdb-.  (末尾的a ,b-代表不同的IDE硬盘) SCSI:设备名为/dev/sda, /dev/sdb-.(末尾的a,b-代表不用的SCSI硬盘 机械式硬盘: track: 磁道(盘面上由外向里划分成不同的磁道) cylinder: 柱面

linux命令练习:磁盘管理相关练习

  练习一   1.写一个脚本 1)显示一个菜单给用户 d|D) show disk usages. m|M) show memory usages. s|S) show swap usages. *) quit. 2) 当用户给定选项后显示相应的内容: 扩展: 当用户选择完成,显示相应信息后,不退出:而让用户再一次选择,再次 显示相应的内容:除了用户使用quit. #!/bin/bash #program: #练习磁盘管理相关脚本编写 #history  donggen  2016-11-03

MBR与GPT分区的区别及磁盘分区相关命令

一.MBR分区结构 主引导记录(Master Boot Record,缩写:MBR),又叫做主引导扇区,是目前比较流行的一种分区结构.磁盘的0磁道0扇区称为MBR,它的大小是512字节,这个区域被分为三个部分: 第一部分为boot loader(主引导程序),占446字节: 第二部分为Partition table(分区表),即DPT,占64字节,每个分区项占用16个字节,这16个字节中存有活动状态标志.文件系统标识.起止柱面号.磁头号.扇区号.隐含扇区数目(4个字节).分区总扇区数目(4个字节

Linux基础--进程管理相关命令介绍(2)

本文主要介绍了Linux中进程管理的相关命令,涉及到的主要命令有top,vmstat等. (1)top ①功能:用来查看CPU,内存以及进程的状态. ②用例: ③相关注释: load average表示负载,三个数值分别表示第1分钟,第5分钟,第10分钟 Cpu中us表示用户空间程序占用百分比,sy表示内核模式占用百分比,ni表示调整NICE值所占用的    CPU百分比,id表示CPU的空闲比例,wa表示等待磁盘IO完成所占用的时间比例,hi表示硬件中断占     据的百分比,si表示软中断所

Linux基础--进程管理相关命令介绍(1)

本文主要介绍了Linux中进程管理的相关命令,涉及到的主要命令有pstree,ps. (1)pstree ①功能:用来查看进程树 ②用例: (2)ps ①功能:用来显示系统当前进程状态的命令 ②用例: ③相关用法: ps a:显示所有跟终端相关的进程 ps x:显示所有跟终端无关的进程 相关注释: STAT各代码含义: S:可中断的睡眠态 D:不可中断的睡眠态 R:运行或可运行 T:停止 Z:僵死 s:session leader l:多线程进程 +:前台进程 N:低优先级进程 <:高优先级进程

SELinux的策略与规则管理相关命令seinfo、sesearch、getsebool、setsebool、semanage

SELinux的策略与规则管理相关命令:seinfo命令.sesearch命令.getsebool命令.setsebool命令.semanage命令. seinfo 命令 seinfo命令是用来查询SELinux的策略提供多少相关规则,一个主体进程能否读取到目标文件资源的重点是在于SELinux的策略以及策略内的各项规则,然后再通过该规则的定义去处理各项目标文件的安全上下文,尤其是"类型"部分. -A:列出SELinux的状态.规则布尔值.身份识别.角色.类型等所有信息. -t:列出S

Linux中快捷键的使用,who命令,rm命令,ps命令,cd命令,kill命令,find命令,grep命令,tar命令(gz、tar、bz2),相关命令

1.进入Ubuntu之后打开终端窗口的快捷键是: ctrl + alt+t:通过这个命令可以打开终端.截图是: 2.关闭一个终端窗口的方式是: Alt +F4,在Ubuntu下还可以是exit 3.对于terminal中的符号,其中的$标识,普通用户时显示的是$,超级管理员对应的符号是:# 截图如下: 4.whoami:查看我是谁的命令,截图如下: 通过whoami或者who命令查看当前用户 5.清屏的命令是: clear,快捷键是:ctrl + l 6.查看当前所在位置的命令是:pwd 7.c

day14-磁盘管理df/du/fdisk/parted命令

4.1:df命令: 总称:report file system disk space usage 1.df:用来查看系统磁盘容量(总容量 已使用及剩余容量.)使用情况:默认是以KB为单位显示: 语法:df  [ 选项 ] 参数 选项如下: -h:使用合适的单位显示: -i:查看inode的使用情况: -k:以KB为单位显示: -m:以MB为单位显示: -a:显示系统中在用的所有分区(不常用) [[email protected] ~]# df                 #默认df时,以KB

linux基础篇-22,硬盘相关命令ln df mknod fdisk

MBR:Master Boot record主引导记录(512byte字节) bootloader:446byte 标示分区:16byte标示一个分区(一共64byte) 标示MBR是否有效:2byte Magic Number ################################################ ln ln [选项]... 目标         (第二种格式) -s, --symbolic        创建符号链接而非硬链接 -v, --verbose