Take notes on Linux Private food from laruence (4) -- files

Source: Internet
Author: User

I. Check files

Use ls-l to view the detailed information of the object in long mode, contains the disk space used by the current directory, file type, File Permission, hard connections, file owner, file group, file size, change time, and file name.

Use file to check the file type

Because the file name in linux does not have an extension, you may need to use file to view the file type.

Ii. File Type

In linux, everything is treated as a file.

A letter before the File Permission is used to indicate the file type:

-: General Files

D: directory file

B: block Device Files (such as hard disks)

C: character device files (for example, keyboard and mouse)

L: Link file (equivalent to the shortcut in Window)

P: Artificial Pipeline

Iii. File Permissions

For each file, Linux provides a File Permission System.

The file permission system divides users of Operation files into three types:

File owner (u)

Member of the file group (g)

Other users (0)

Iv. File Permission types

The permission system provides three permissions for each type of users.

Read (r): whether the user has the right to read the file content

Write (w): whether the user has the right to change the File Content

Execution (x): whether the user has the right to execute the file

-Rw-r --: indicates that this is a general file. The owner has read and write permissions, the group has read permissions, and others have read permissions.

1:

Root: The first root represents the owner of the file, and the second root represents the group to which the file belongs.

1089: indicates the file size.

Apr 26 04: 27: indicates the modification time.

Anacoda-ks.cfg: File Name

5. Change File Permissions

Use chmod to change the current permission of the file

Chmod [-R] Permission file name

Only the file owner and root can change the File Permission.

Rw-r --

Chmod u + x install. log # adds an execution permission to the file owner (u: indicates the file owner, x: indicates the execution permission)

Chmod u-x install. log # cancel the execution permission of the file owner

Chmod u = rwx # grant all permissions to the file owner

R w x

4 2 1

Rw-r --

6 44

Chmod 644 # grant the rw -- r -- permission (in numbers) to the file)

Chmod-R 644 # change Directory Permissions

6. Create a link

Hard link: New Link name of ln source file

Soft connection: New Link name of the ln-s source file

Input content to the original file/home/test.txt

The content in the hard link tom.txt is consistent with that in/home/test.txt.

Delete the original file/home/test.txt

You can see that the hard link still exists, and the content is still in it. The above is a hard link. Let's take a look at the soft link:

First create a new/home/test.txt file with the input string

Create soft link

Let's Delete the original file to see if the soft link can still be opened.

Hard links cannot be created for directories, but soft links can be created.

Next we will create a file in the above jack directory and check whether this file exists in its soft link jack1.

VII. Composition of files in ext2/3

In ext2 and ext3 file systems, files exist in inod + block mode.

Once you use the rm command to delete inode records in the file. Files cannot be retrieved.

The stat command can be used to check the block and inode status of a file.

8. User

Each file has an owner. The object owner can change the object ACL.

Root users can use chown to change the object owner.

9. Group

Each file can belong to only one specified group.

The file owner and root user can use chgrp to change the file group.

You can also use chown to change the owner and group of the file at the same time.

10. File Name

The file name cannot exceed 255 characters.

Files starting with. are hidden files.

 

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.