Linux Study Notes (3)-file system, linux Study Notes

Source: Internet
Author: User

Linux Study Notes (3)-file system, linux Study Notes

  • Three types of files
    • Common files: including text files, data files, and executable binary Program Files
    • Directory file: in linux, a directory is viewed as a special file, which forms the tree structure of the file system.
    • Device File: the device is also seen as a file, such as your mouse, your hard disk, and so on in linux.

  • File type identifier

    As mentioned above, linux has a variety of different file types, and the processing methods for different files must be different. For example, the processing methods for common files and directory files must be different, so how does the system identify it ?, Use different codes in file attributes to mark them.

    The following is the encoding of different files.

    • Common file (-)
    • Directory (d)
    • Symbolic Link (l)
    • Character device file (c)
    • Fast device file (B)
    • Socket (s)
    • Named Pipe (p)

    Use commands to view the file type

    # Ls-l

    For example, in the test folder, there is a drwxr-xr-x in front, where the first encoding d is a directory, and so on.

    You can find character device files, fast device files, and connection files in the/dev directory!

  • File Permission

    The permission system of a file is divided into three parts, which are based on the user's attributes.

    • Permissions of the object owner (u)
    • Member permission of the file group (g)
    • Other user permissions (o)

    File Permission types are also divided into three parts

    • Read r (Read): For a file, you have the permission to Read the file content; for a directory, you have the permission to browse the directory.
    • Write w (Write): For a file, you have the permission to repair the file content. For a directory, you have the permission to delete or move files in the directory.
    • EXecute x (eXecute): indicates that the user has the permission to eXecute the file. For a directory, the user has the permission to access the directory.

    For example

    -Rw-r --

    The first "-" indicates that the file is a common file.

    The following "rw-" indicates that the object owner has read and write permissions.

    The following "r --" indicates that the same group of users to which the file belongs only have the read permission.

    The following "r --" indicates that other peers only have read permission.

  • File Permission modification command

    You can use chmod to modify file permissions.

    Format: chmod [-R] {[ugoa] [+-=] [rwx]} <file name or directory NAME>

    Note: [] in the format indicates that this option is optional, {} indicates that it is a whole, and <> indicates a required parameter.

    Meaning of different options

    • -R: If a directory is operated, it indicates recursively implementing the same permission settings for all sub-projects in the directory.
    • User)
    • G indicates the user in the group)
    • O indicates other users (other)
    • A Indicates all users (all)

    +-= Indicates adding, deleting, and setting respectively.

    Instance operations

    Create a new test.txt File

    # Touch test.txt

    # Ls-l

    The owner has read and write permissions.

    Add execution permission to it

    # Chmod u + x test.txt

    # Ls-l

    Chmod can also use three digits to change the File Permission.

    The first permission indicates the permission of the owner of the file.

    The second digit indicates the permission of the group to which the file belongs.

    The third digit indicates the permissions of other users of the file.

    4 (read) R

    2 (write) W

    1 (execution) X

    # Chmod 700 test.txt

    # Ls-l

    The master of the Test.txt file has the read and write permissions, and other users do not have any permissions. This is very convenient.

  • Modify the owner and group of an object

    You can use the chown command to change the user and user group permissions of a file or directory.

    Note: before execution, ensure that the user and user group already exist in the system.

    First, user1 user2 is available. The Group has group1 group2.

    Change testfile from user1 to user2 and user1 to group2.

    # Chown user2: group2 testfile

    # Conclusion #

    Once again, come on!

     


In linux, how does one specify the file system type as ext3?

Format the fdisk partition:
Mkfs. ext3/dev/sdb1

/Dev/sdb1 is the partition of your new hard disk.

Is the EXT3 File System Log required in linux?

Ext3 log file system features
1. High Availability
After the system uses the ext3 file system, the system does not need to check the file system even after it is shut down abnormally. After a crash occurs, it takes tens of seconds to restore the ext3 file system.
2. Data Integrity:
The ext3 file system can greatly improve the integrity of the file system and avoid unexpected downtime damage to the file system. There are two modes available for ext3 file systems to ensure data integrity. One of them is the "Maintain file system and data consistency at the same time" mode. In this way, you will never see junk files stored on the disk due to abnormal shutdown.
3. File System speed:
Although the ext3 file system may have to write data multiple times during data storage, in general, ext3 is better than ext2. This is because the log function of ext3 optimizes the disk drive read/write headers. Therefore, the read/write performance of the file system is not lower than that of the Ext2 file system.
4. Data Conversion
It is very easy to convert an ext2 file system to an ext3 file system. Simply Type Two commands to complete the conversion process. You do not need to take the time to back up, restore, and format partitions. Use the tune2fs tool provided by an ext3 File System to easily convert the ext2 file system to an ext3 log file system. In addition, the ext3 file system can be directly loaded into the ext2 file system without any changes.
5. Multiple log Modes
Ext3 has multiple log modes, one of which is to define the data in the file system, that is, the data of all file data and metadata) logging (data = journal mode); another mode is to record logs only for metadata, but not for data, that is, the so-called data = ordered or data = writeback mode. System Administrators can choose between system speed and file data consistency based on the actual work requirements of the system.

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.