CentOS File System parsing and related commands

Source: Internet
Author: User
Tags windows dll files

CentOS File System parsing and related commands

Introduction

A file system is a logical set of all files in a partition or disk.

The file system contains not only the data in the file but also the structure of the file system. All files, directories, soft connections, and file protection information seen by Linux users and programs are stored in the file system.

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

There are multiple types of file systems, such:

  • Ext2: common file systems in early linux;
  • Ext3: an upgraded version of ext2 with the log function;
  • RAMFS: memory file system, fast;
  • Iso9660: optical disc or optical disc image;
  • NFS: A Network File System invented by SUN. It is mainly used for remote file sharing;
  • MS-DOS: MS-DOS file system;
  • FAT: The file system used by Windows XP;
  • NTFS: The file system used by the Windows NT/XP operating system.
Partitions and directories

The file system is located in the disk partition. One hard disk can have multiple partitions or only one partition. One partition can only contain one file system.

There is a big difference between Linux and Windows. Windows File structure is a parallel tree structure with different disks (partitions) at the top, such as C, D, E, and F.

The file structure of Linux is a single tree structure. The root directory is "/", and other directories must be located under the root directory.

Every time we install the system, we will partition. The relationship between disk partitions and directories in Linux is as follows:

  • Any partition must be mapped to a directory to perform read/write operations ".
  • The mounted directory can be the root directory or another level-2 or level-3 directory. Any directory can be a mount point.
  • Directories are logically differentiated. Partitions are physically differentiated.
  • The root directory is where all Linux Files And Directories are located. You need to mount a disk partition.


Is a common ing between directories and partitions:

Why partition and how to partition?

  • Different data can be managed in different partitions to reduce risks.
  • Large Hard Disk search range, low efficiency.
  • /Home,/var,/usr/local are often independent partitions, because operations are often performed and fragments are easily generated.


For ease of locating and searching, each directory in Linux generally stores specific types of files. The following table lists common directories of various Linux Release versions:

DirectoryDescription/Root directory, which can only contain directories and cannot contain specific files. /Bin stores executable files. Many Commands correspond to a program in the/bin directory, such as ls, cp, and mkdir. The/bin directory is valid for all users. /Dev hardware driver. For example, sound card, disk drive, and files such as/dev/null,/dev/console,/dev/zero,/dev/full. /Etc mainly contains system configuration files, user and user group configuration files. /Lib mainly contains shared library files, similar to Windows DLL files; sometimes it also contains kernel-related files. /Boot system startup files, such as Linux kernel and boot program. /Home user's working directory (main directory), each user will allocate a directory. /Mnt mount the file system temporarily. This directory is generally used to store the Mount directory of the mounted storage device, such as the cdrom directory to mount the CD-ROM. When the/proc operating system is running, the process (Program in progress) information and kernel information (such as cpu, hard disk partition, memory information, etc.) are stored here. The/proc directory is the mounted directory of proc, which is not a real file system. /Tmp temporary file directory, which will not be saved after the system is restarted. Files in the/usr/user directory are mixed, including management commands, shared files, and library files, which can be used by many users. /Var mainly contains variable-length files that often read and write data, such as log files and files in the print queue. /Sbin is similar to/bin, which mainly contains executable files. However, it is generally required by system management, not all users need it.Common file management commands

You can use the following command to manage files:

CommandDescriptionCat filename: view the file content. Change the directory where the cd dirname is located. Cp file1 file2: copy the file or directory. File filename: the file type (binary, text, etc ). Find filename dir searches for files or directories. Head filename indicates the beginning of the file, which is opposite to the tail command. The less filename command allows you to view all the content of a file and display it by page. It is more powerful than the more command. Ls dirname traverses the files or directories in the directory. Mkdir dirname: create a directory. More filename: view all the content of the file, which can be displayed by page. Mv file1 file2 move or rename the file. Pwd displays the current directory of the user. Rm filename: delete the file. Rmdir dirname: Delete the directory. Tail filename displays the end of the file, which is opposite to the head command. When the touch filename file does not exist, an empty file is created and the file timestamp is modified when it exists. Whereis filename to view the file location. 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 to manage disk partitions. the df-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$

The meaning of each column is as follows:

ColumnDescriptionFilesystem indicates the path name of the device file corresponding to the file system (usually the partition on the hard disk ). The number of data blocks (1024 bytes) contained in the kbytes partition. Used space in use. Avail available space. Percentage of space used by capacity. Mounted on file system mount point.


For some directories (such as/devices), the kbytes, used, and avail columns are 0 and the use column is 0%. These are special (or virtual) file systems, even if they are in the root directory, it does not occupy hard disk space.

You can combine the-h (human readable) option to format the output information, making it easier to read.

Du command

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

The du command displays the data blocks occupied by each directory. Depending on the system, a data block may be 512 bytes or 1024 bytes. Example:

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

Combined with the-h option, the information can be displayed more clearly:

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

Mount a File System

Attaching a hardware device (such as a hard disk, USB flash disk, or CD) to an existing Directory. To access a file in a device, you must mount the file to an existing Directory and access the storage device by accessing the directory.

In this way, a unified interface is provided for users to block the details of hardware devices. Linux regards all hardware devices as files, and operations on hardware devices are equivalent to operations on files.

Note: The Mount directory may not be empty, but the contents in the directory will not be available after mounting.

You need to know that the formats of the file systems used by CD, floppy disk, and other operating systems are different from those used by linux, to mount a file system, check whether Linux supports the format of the file system to be mounted.

To view the hardware devices mounted to the current system, run the mount command:

$ mount/dev/vzfs on / type reiserfs (rw,usrquota,grpquota)proc on /proc type proc (rw,nodiratime)devpts on /dev/pts type devpts (rw)$

Generally,/mnt is a temporary Mount directory, such as attaching a CD-ROM, a remote network device, or a floppy disk.

You can also mount the file system by running the mount command. 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 be left unspecified. in Linux, the file system type is automatically and correctly selected.

After mounting the file system, you can use commands such as cd and cat to operate the corresponding file.

You can run the umount command to uninstall the file system. For example, uninstall cdrom:

$ umount /dev/cdrom

However, most modern Linux systems have the automatic Mount/unmount function, and the unmount command is rarely used.

User and group quota

Quota of users and groups allows administrators to allocate a fixed disk space for each user or group.

The administrator can allocate disk space in two ways:

  • Soft limit: if the user exceeds the specified space, there will be a grace period, waiting for the user to release the space.
  • Hard limit: no grace period exists. operations are immediately prohibited if the specified space is exceeded.


The following command can be used to manage a quota:

CommandDescriptionQuota Displays disk usage and quota of each user group. Edquota edits the quota of users and groups. Check the disk usage of the file system, and create, check, and repair the quota file. Setquota: set the quota. Quotaon enables the user or group quota function. Quotaoff disables the user or group quota function. Repquota prints the quota of the specified file system.

Thank you! Thank you for your patience!

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.