Home >System Tutorial >LINUX >How to query the number of partitions in Linux system

How to query the number of partitions in Linux system

PHPz
PHPzOriginal
2024-03-01 17:39:04937browse

How to query the number of partitions in a Linux system requires specific code examples

Linux is a widely used operating system with strong flexibility and customizability. In Linux systems, partitioning a hard disk is a common operation. Different partitions can be used to store different types of data or install different operating systems. Therefore, it is very important to know how to query the number of partitions in the system. The following will introduce how to query the number of partitions in a Linux system and provide specific code examples.

1. Use the fdisk command

fdisk command is a tool for processing disk partitions and can be used to query the partitions that exist in the system quantity. The following are the specific steps to use the fdisk command to query the number of partitions:

  • Open the terminal and enter the following command to view the system disk information:
sudo fdisk -l
  • Enter the system password and press the Enter key. The system will list the partition information of all disks, including the number, size, type, etc. of partitions. You can use the output information to determine the number of partitions in the system.

2. Use the lsblk command

lsblk command is a tool for listing block device information, which can help us query Information about each disk and partition in the system. The following are the specific steps to use the lsblk command to query the number of partitions:

  • Open a terminal and enter the following command to list the block device information in the system:
lsblk
  • The system will list all block device information, including disks, partitions, mount points, etc. You can use the output information to determine the number of partitions in the system.

3. Use the df command

df command is a tool used to query the disk space usage of the file system. By viewing The mount point information can tell the number of partitions in the system. The following are the specific steps to use the df command to query the number of partitions:

  • Open the terminal and enter the following command to view the file system disk space usage:
df -h
  • The system will list the mount points and disk space usage of all file systems, including the number of partitions. The number of partitions in the system can be determined based on the mount point information.

Through the above method, you can easily query the number of partitions in the Linux system. Choose the method that suits you for querying, and view the corresponding information as needed. Hope the above content is helpful to you!

The above is the detailed content of How to query the number of partitions in Linux system. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn