Linux basic commands (2) commands on disk space, linux disk space

Source: Internet
Author: User

Linux basic commands (2) commands on disk space, linux disk space
Disk Space commands

Command Function
Mount Mount a File System
Umount Detach a mounted file system
Df Check the disk space of each hard disk partition and mounted file system
Du Show file directory and size
Fsck It mainly checks and fixes the Linux File System.
2.1 mount command

The mount command can be used to mount a file system, such as a hard disk, a CD, or a floppy disk, or an NFS Network File System. The standard usage of this command is as follows:

Mount-t device type storage directory
Mount IP Address:/directory of the provided directory

Option Description
(None) Without adding any parameters, enter a command to display the mounted file system and directory.
- Mount all file systems under/etc/fstab
-T Specify the name of the mounted file system, which is supported by all systems. This information can be seen in the/proc/filesystems file.
-N Mount the file system, but do not write data from the file system to the/etc/mtlab file.
-W Set the file system to read/write
-R The mounted file system is set to read-only.

Mount the iso9660 File System under the directory/mnt. Enter the following command:

Mount-t iso9660/dev/hdb/cdrom

2.2 umount command

The umount command is used to detach a mounted file system. Before shutting down the system, detach all mounted file systems. This command is opposite to the mount command. Usage:

Umount mounted directory or device

Uninstall the mounted/cdrom directory and enter the following command:

Umount/cdrom

To detach a mounted partition, run the following command:

Umount/dev/hdb1

2.3 df command

The df command is used to check the disk space of the hard disk partition and the mounted file system, that is, to check the disk usage. The standard usage is as follows:

Df [-Option]

Option Function
- List all the file systems and the hard disk usage of each partition, including Block 0, such as the/proc file system.
-I List the I-nodes usage
-K K Represents the size of each partition and the size of the mounted file partition.
-T List the disk space usage of all partitions in a file system
-X List the disk space usage of all partitions of a file system, which is opposite to the-t option.
-T Lists the names of the file systems to which each partition belongs.

For example, to list the disk usage of all file systems and partitions, enter the following command:

Df-

2.4 du command

The du command is used to display the file directory or size. Standard usage:

Du [-Option]

Option Description
- Displays the disk space occupied by each file in all directories and their directories.
-B Displays the Directory and file size, in Unit B.
-C Add a total.
-H Improves information readability in units of KB, MB, and GB
-S Only list the total size of each file
-X Calculate only files belonging to the same file system
2.5 fsck command

The function of the fsck command is to check and repair the Linux File System. It is best to use this command when no one or no partitions are mounted. In fact, each time the system is started, a check will be performed, check whether there is a bad track or data loss. Usage:

Fsck (-option) Partition name

Option Function
- It is dangerous to automatically repair the file system without asking any questions.
- Check all file systems listed in the/etc/fstab configuration file. If the parameter "-P" is not attached, the/directory file system is checked first, instead of all file systems.
-R Use interactive methods to ask questions when fixing, and ask the user to confirm and determine the handling method.
-S Check jobs in sequence instead of executing them at the same time. When multiple file systems are specified in sequence and checked in interactive mode, use this parameter for sequential execution. Otherwise, the fsck may ask several questions at the same time, which is confusing.
-V Display the Command Execution Process
-T Type of the file system to be checked
-N Not a real execution command. Only actions performed during actual execution are listed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.