Home >Computer Tutorials >Computer Knowledge >Common commands for managing file systems and disks in Linux!
In Linux systems, file system management and disk management are one of the necessary skills for operation and maintenance engineers, and they are very important parts of the operating system, so they are also provided There are many commands and tools, so how does Linux manage file systems and disks? The following is a detailed introduction.
In a Linux system, to manage file systems and disks, you can use some basic commands and tools, such as fdisk, parted, mkfs, mount, df, etc.
1. View file system and disk information
Before managing file systems and disks in a Linux system, you must first understand the file system and disk information in the system. You can use the following commands to view disk and file system information in the system:
# View hard disk information
sudo fdisk -l
# View file system information
sudo df -h
2. Disk partitioning and formatting
In a Linux system, to use a disk, you need to partition it and format the partition. Disks can be partitioned using the fdisk and parted tools.
# Use fdisk to partition the disk
sudo fdisk /dev/sdb
# Use parted to partition the disk in MB
sudo parted/dev/sdb
(parted)
(parted)print
(parted)unit MB
(parted)mklabel gpt
(parted)mkpart primary 0 1000
(parted)print
(parted)quit
After the partitioning is completed, each partition needs to be formatted. Commonly used formatting commands include mkfs.ext4, mkfs.ntfs, mkfs.fat32, etc.
# Format partition
sudo mkfs.ext4 /dev/sdb1
3. Mounting and unmounting file systems
In the Linux system, the file system needs to be mounted to the specified path for use. You can set the option of automatic mounting of the card machine in the /etc/fstab file.
# Mount file system
sudo mount /dev/sdb1/mnt
# Uninstall file system
sudo umount /mnt
4. Expand or shrink the file system
During use, you may need to expand or shrink the file system. You can use the resize2fs command.
#Expand the current file system
sudo resize2fs /dev/sdb1
The above is the detailed content of Common commands for managing file systems and disks in Linux!. For more information, please follow other related articles on the PHP Chinese website!