Linux file system parsing and related commands

Source: Internet
Author: User
Tags disk usage

Brief introduction

A file system is a logical collection of all the files on a partition or disk.

The file system contains not only the data in the file but also the structure of the file system , in which all Linux users and programs see files, directories, soft links, and File Protection information.

There are few file system differences between different Linux distributions, mainly in the system management of the unique tools and software package management methods, the file directory structure is basically the same.

There are several types of file systems, such as:

    • Ext2: A file system commonly used in early Linux;
    • EXT3:EXT2 upgrade version, with log function;
    • RAMFS: Memory file system, fast;
    • ISO9660: disc or disc image;
    • NFS: Network File system, invented by sun, is mainly used for remote file sharing;
    • Ms-dos:ms-dos file system;
    • Fat:windows XP operating system used by the file system;
    • Ntfs:windows the file system used by the NT/XP operating system.
Partitions and directories

The file system is located in a disk partition; A hard disk can have multiple partitions or only one partition, and a partition can contain only one file system.

There is a big difference between Linux file systems and Windows. The file structure of Windows is a multi-side tree structure, with different disks (partitions) at the top, such as C, D, E, F, and so on.

  The file structure of Linux is a single tree structure, the root directory is "/", the other directories are located in the root directory .

Each time we install the system, we will partition, Linux under the disk partition and directory relationship is as follows:

    • Any partition must be mapped to a directory for read and write operations, called "mounts."
    • The mounted directory can be a root directory or another level two, level three directory, and any directory can be a mount point.
    • A directory is a logical distinction. Partitioning is a physical distinction.
    • The root directory is where all Linux files and directories reside, and the previous disk partition needs to be mounted.


is a common directory and partition correspondence relationship:

Why partition, how to partition?

    • Different data can be put into different partitions to manage, reduce the risk.
    • Large hard drive search range, low efficiency.
    • /home,/Var,/usr/local are often separate partitions because they are often manipulated and prone to fragmentation.


To facilitate location and lookup, each directory in Linux typically holds specific types of files, and the following table lists common directories for various Linux distributions:

Catalogue Description
/ The root directory, which can contain only directories, cannot contain specific files.
/bin Store the executable file. Many commands correspond to a program in the/bin directory, such as LS, CP, mkdir. The/bin directory is valid for all users.
/dev Hardware drivers. such as sound card, disk drive, etc., also like/dev/null,/dev/console,/dev/zero,/dev/full and other files.
/etc It mainly contains the system profile and user, user group profile.
/lib It mainly contains shared library files, similar to DLLs under Windows, and sometimes contains kernel-related files.
/boot system boot files, such as the Linux kernel, boot programs, and so on.
/home User working directory (home directory), each user will be assigned a directory.
/mnt Temporarily mount the file system. This directory is typically used to store mount directories for mounted storage devices, such as the CDROM directory where the CD-ROM is mounted.
/proc When the operating system is running, the process (running program) information and kernel information (such as CPU, hard disk partition, memory information, etc.) are stored here. The/proc directory disguises the file system proc mount directory, Proc is not the real file system.
/tmp Temporary file directory, which will not be saved after the system restarts.
/usr /user The file is mixed, including management commands, shared files, library files, etc., can be used by many users.
/var Mainly includes some variable-length files, which often read and write data, such as log files and files in the print queue.
/sbin Similar to/bin, mainly contains executables, but is generally required for system management, not all users need.
Common file Management commands

You can use the following command to manage files:

Command Description
Cat filename View the contents of the file.
CD dirname Change your directory.
CP file1 File2 Copy the file or directory.
File filename View file types (binary, text, etc).
Find filename dir Search for files or directories.
Head filename Displays the beginning of the file, as opposed to the tail command.
Less filename View the entire contents of a file, which can be displayed on a page, more powerful than the more commands.
LS dirname Traverse a file or directory under a directory.
mkdir dirname Create a directory.
More filename View the entire contents of a file, which can be displayed in pagination.
MV File1 File2 Move the file or rename it.
Pwd Displays the directory where the user is currently located.
RM filename Delete the file.
RmDir dirname Delete the directory.
Tail filename Displays the end of the file, relative to the head command.
Touch filename The file does not exist when an empty file is created and the file timestamp is modified when it exists.
Whereis filename See where the files are located.
which filename If the file is defined in the environment variable path, the file location is displayed.
DF command

The DF (disk free) command is often used when managing disk partitions, and thedf-k command can be used to view disk space usage (in kilobytes), for example:

$DF-kfilesystem      1k-blocks      used   Available use% mounted on/dev/vzfs        10485760   7836644     2649116  75%//devices                0         0           0   0%/devices$

Each column has the following meanings:

column Description
Filesystem The path name of the device file that represents the file system (typically, the partition on the hard disk).
Kbytes The number of data blocks (1024 bytes) that the partition contains.
Used Already used space.
Avail Free space.
Capacity The percentage of space that has been used.
Mounted on File system mount point.


Some directories, such as/devices, Kbytes, used, and avail, are listed as 0,use 0%, which are special (or virtual) file systems that do not occupy hard disk space, even if they are located in the root directory.

You can format the output information in conjunction with the-H (Human readable) option, making it easier for people to read.

Du command

The Du (disk usage) command can be used to view the space usage of a particular directory .

The du command displays the block of data that each directory occupies . Depending on the system, a block of data may be 512 bytes or 1024 bytes. Examples are as follows:

$du/etc10     /etc/cron.d126    /etc/default6      /etc/dfs...$

Combine the-h option to make the information appear clearer:

$du-H/etc5k    /etc/cron.d63k   /etc/default3k    /etc/dfs...$

Mount File System

  Mount refers to a hardware device (such as a hard disk, USB flash drive, CD-ROM, etc.) corresponding to an existing directory . To access a file on a device, you must mount the file to an existing directory and access the storage device by accessing the directory.

This provides the user with a unified interface, shielding the details of the hardware device. Linux considers all hardware devices as files, and the operation of the hardware device is equivalent to the operation of the file.

Note: The mount directory may not be empty, but the previous content under this directory will not be available after mounting.

What you need to know is that the format of the file system used by the CD, floppy disk, and other operating systems is not the same as the file system format used by Linux, and the Mount needs to confirm that Linux supports the file system format to be mounted.

To view the hardware devices that are mounted on the current system, you can use the Mount command:

$ MOUNT/DEV/VZFS on/type reiserfs (rw,usrquota,grpquota) proc On/proc type proc (rw,nodiratime) devpts on/dev/pts type D Evpts (rw) $

Generally,/MNT is a temporary mount directory, such as Mount CD-ROM, remote network device, floppy disk, and so on.

The Mount command can also be used to mount the file system with the following syntax:

Mount-t File_system_type Device_to_mount directory_to_mount_to

For example:

$ mount-t Iso9660/dev/cdrom/mnt/cdrom

Mount the CD-ROM to the/mnt/cdrom directory.

Note: File_system_type is used to specify the file system type, which can usually be unspecified, and Linux automatically chooses the file system type correctly.

Once the file system is mounted, the corresponding files can be manipulated by commands such as CD, Cat, and so on.

You can uninstall the file system by using the Umount command. For example, uninstall CDROM:

$ umount/dev/cdrom

However, most modern Linux systems have automatic mount offload, and unmount commands are rarely used.

User and group quotas

  User and group quotas allow administrators to assign a fixed amount of disk space to each user or group.

Administrators have two ways to allocate disk space:

    • Soft limit: If the user exceeds the specified space, there will be a grace period waiting for the user to free up space.
    • Hard limit: No grace period, no action is allowed immediately beyond the specified space.


The following commands can be used to manage quotas:

Command Description
Quota Displays disk usage and quotas for each user group.
Edquota Edit quotas for users and groups.
Quotacheck View the disk usage of the file system, create, check, and repair quota files.
Setquota Set quotas.
Quotaon Turn on the quota function for users or groups.
Quotaoff Turn off the quota feature for users or groups.
Repquota Prints quotas for the specified file system.

Http://www.cnblogs.com/0201zcr/p/4773995.html

Linux file system parsing and related commands (RPM)

Related Article

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.