Linux Learning notes----9

Source: Internet
Author: User

Accessing the Linux file system

1. Identify file systems and equipment

A file system is an ordered structure of files and directories that hold data, aggregating all file systems into a single directory tree with an individual heel. Existing hierarchies can be extended at any time: simply add new disks or partitions that contain supported file systems to increase disk space anywhere in the file system tree. The process of adding a new file system to the current directory tree is called mounting, where the directory where the new file system is mounted is called a mount point.

A storage device is represented by a special file type, which becomes a block device. The block device is stored in the/dev directory.

Serverx the special file type for the block device is b

/DEV/SDA first Scsis,sata or USB drive

/DEV/SDB1 the first partition of the second hard drive

/DEV/VD or/dev/xvd a hard drive in a virtual machine


Another way to defragment disks and partitions is to manage LVM through logical volumes. With LVM, one or more block devices can be pooled into one storage pool, called a volume group. Disk space can be provided by one or more logical volumes that are equivalent to the partitions residing on the physical disk. Both volume groups and logical volumes are assigned a name when they are created. For a volume group, there is a directory with the same name as the volume group in the/dev directory, under which a symbolic link with the same name as the logical volume has been created. For example, the device file for the MYLV logical volume in the MYVG volume group is/DEV/MYVG/MYLV.

LVM relies on the device mapper DM kernel driver. The/DEV/MYVG/MYLV points to the/dev/dm-number block device node, and number is contiguous, starting with 0, and the number name is different at each startup.

Each logical volume has another symbolic link in the/dev/mapper directory with the name/DEV/MAPPER/MYVG-MYLV, which can often be accessed using any reliable and consistent symbolic link to access the logical volume.


Check the file system

DF View File system mount point and free space size

Df-h units are KiB, Mib, Gib

Df-h units are KB, MB, Gb

Du view more information about the space used by a particular directory tree


2. Mount and unmount the file system

File systems residing with SATA or SCSI devices need to be manually mounted before they can be accessed. The Mount command allows the root user to mount the file system manually.

Format: Mount the file system mount point to Mount

The Blkid command briefly lists the UUID of the existing partition and file system with the file system, and the file system used to format the partition

The file system can be mounted to an existing directory. /MNT is present by default, it provides a portal for mount points, it is recommended to create subdirectories under/MNT and use that subdirectory as a mount point for easy administration.

If the directory used for the mount point is not empty, all files written to the mount point directory will appear in the file system mounted here as long as the file system is mounted to the directory where the existing file is inaccessible.


Uninstalling the file system

Format: Umount mount point

If the mount point is being accessed by a process, it cannot be uninstalled and requires the process to stop accessing the mount point.

Lsof mount points lists all open files in the specified directory and the access process


Removable media such as USB flash devices and drives are automatically mounted by the graphical desktop environment after they are inserted, and the mount point is:/run/media/<user>/<label>

<user> the user who logged in to the graphical environment <label> the name taken when the file system was created


3, the production of links between documents

Hard link: A hard link is a new directory entry that references an existing file in the file system, and each file in the file system has a hard link by default. All hard links that point to the same file have the same permissions, user/group ownership, timestamp, and file contents. After a new connection is created, you cannot distinguish which is the original link. Even if the original file is deleted, the contents of the file remain available as long as there is at least one hard link. If the task information on a hard link is changed, any hard links that point to the same file will also display the new content.

Format: ln source file hard-link file


Soft Links: Also known as symbolic links, soft links are special file types that point to existing files and directories and can also point to files or directories in other file systems. A soft link can point to a directory and can be used as a directory when pointing to a directory. When the original file is deleted, a soft link will point to the file but is not available, called a dangling soft link.

Format: ln-s source file/directory Soft link File/directory


4. Find files in the system

The locate:locate command returns results based on the file name or path in the locate database, which stores the file name and path information. When searching with a normal user, you must have read access to more than a matching directory tree

Example: Locate passwd search passwd

Locate-i passwd Case insensitive

Locate-n 5 passwd Limit number of returned results

Locate database is automatically updated daily, root can update the database by UpdateDB command


The Find:find command performs a search on the local file system and finds files that match the conditions of the command line parameters. The Find command queries files in the file system as your Ming Lake account, and the user who invokes the Find command must have read and execute permissions to the directory where the content is to be viewed.

Format: Find [directory to search] option---------if argument is omitted, the current directory is searched

If you use wildcard search, be sure to enclose the name of the file you want to find in quotation marks to prevent the terminal from interpreting the wildcard symbol

Example:

Find/-name passwd look for a file named passwd

Find/-iname passwd case insensitive

Find/-name ' *pass* ' Look for file name containing pass

Find/-user Lvyang finding files owned by user Lvyang

Find/-group Lvyang finding files owned by user group Lvyang

Find/-user Root-group Mail finds files owned by root and mail group

Find/-perm 755 look for a file with permission 755

Find/-size 1M search for files with size equal to 1M (rounding up)

Find/-size +1m search for files larger than 1M in size

Find/-size-1m search for files less than 1M in size

Find/-type F search for plain files

Find/-type D search Catalog

Find/-type B search block device

Find/-type L Search Soft Links


Linux Learning notes----9

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.