问题
fdisk -l 查看硬盘及分区信息
代码语言:javascript复制[root@CentOS-85-64-minimal ~]# dfisk -l
-bash: dfisk: command not found
原因:命令fdisk 不在你的命令搜索路径中
解决
方法一
先进入root用户,再查看你当前的命令搜索路径:
代码语言:javascript复制[root@CentOS-85-64-minimal ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
再查一下fdisk命令在哪个路径下:
代码语言:javascript复制[root@CentOS-85-64-minimal ~]# whereis fdisk
fdisk: /usr/sbin/fdisk /usr/share/man/man8/fdisk.8.gz
我们可看到fdisk 命令不再当前命令搜索路径里,那么我们将fdisk添加到当前命令搜索路径中即可:
代码语言:javascript复制ln -s /usr/sbin/fdisk /usr/local/bin
好现在已经将fdisk 添加到当前命令搜索目录中去,我们可以去看一下:
代码语言:javascript复制dfisk -l
方法二
不需要添加到环境变量中,直接在sbin目录下运行命令fdisk -l
代码语言:javascript复制[root@CentOS-85-64-minimal sbin]# whereis fdisk
fdisk: /usr/sbin/fdisk /usr/share/man/man8/fdisk.8.gz
然后进去目录:
代码语言:javascript复制cd /usr/sbin
./fdisk -l 或者 ./fdisk
如:
代码语言:javascript复制[root@CentOS-85-64-minimal ~]# cd /usr/sbin
[root@CentOS-85-64-minimal sbin]# ./fdisk -l
Disk /dev/sda: 5.5 TiB, 6000606183424 bytes, 11719933952 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: CCF1F455-14FA-4C11-8331-25A482B2D95F
Device Start End Sectors Size Type
/dev/sda1 4096 33558527 33554432 16G Linux swap
/dev/sda2 33558528 34607103 1048576 512M Linux filesystem
/dev/sda3 34607104 11719933918 11685326815 5.5T Linux filesystem
/dev/sda4 2048 4095 2048 1M BIOS boot
Partition table entries are not in disk order.
Disk /dev/sdb: 446.6 GiB, 479559942144 bytes, 936640512 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x4c63d5b8
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 936640511 936638464 446.6G 83 Linux