Linux Learning Notes---some interesting commands

Source: Internet
Author: User

One

Before we say the link we need to explain a thing, is the inode, a file name can have more than one, but the i-number in the Inode is only a single, (Inode is a data structure, which contains various properties of the file, owner, group, permissions, size, last access time)

Then how to check the I-number? Direct input Ls-li can be viewed (first column)

? Linux Ls-li
Total 20
940224-rw-rw-r--2 Xujie Xujie Nov 21:17 A
940219 lrwxrwxrwx 1 Xujie Xujie 1 Nov 21:18 A1-A
940224-rw-rw-r--2 Xujie Xujie 21:17 b

This is the result of entering Ls-li in the Linux directory, and observing the above results we can find that both A and B are the same except for the same name, stating that A and B are the same two files.

Modifying one of them is equivalent to modifying the other one.

Using the ln a b command, a represents the original file, and B represents a new name for him.

This is like a file with multiple names. Such links are called Hard links.

The second line above shows A1 a, but let's look at the file with LS

? Linux ls
A A1 b

Found only A1, no A1-A, but also can see the A1 file type is L, L for this is a symbolic link file, you can use this link to file A, it has the same permissions as a. So symbolic links can be seen as a shortcut to a file.

It can be implemented by command ln-s a A1.

So now that the links are all set up, if you delete them,

? Linux Ls-li
Total 20
940224-rw-rw-r--2 Xujie Xujie 21:17 A
940224-rw-rw-r--2 Xujie Xujie 21:17 b

You can see that deleting a symbolic link does not have any effect on the original file.

? Linux RM A
? Linux Ls-li
Total 16
940224-rw-rw-r--1 Xujie Xujie 21:17 b

When we removed a hard link, something changed and the number after the permission changed to 1, which is called the number of links to indicate how many links (and how many names) the file has (and by the first result, the letter link does not increase the number of links)

? /Home Ls-li
Total 4
932917 drwxr-xr-x Xujie Xujie 4096 Nov 21:41 Xujie

See the number of links to this file, there are so many, the main reason is under the current directory. and sub-directories: The file is a hard link to it.

So when you delete a file, only the number of links is reduced to 0, and the file is deleted.

  

It is necessary to note that there are two cases where a hard connection cannot be established:

1, can not establish a hard link to the directory, to avoid the occurrence of a circular directory structure, increase complexity. (. and.. Files are created automatically when the system is )

2. If the file is in a different volume, that is, a different file system (or a different disk, the word for Windows) establishes a hard link.

However, symbolic links can be used in all cases.

Two

About file permissions

$ ls-l
-rw-r--r--1 Tux system 1081 June 11:32 file
Drwxr-xr-x 2 Tux System, June 11:32 Man

The first column represents the file type, d: catalog file, L: Symbolic Link file, s: Socket file, B: Block device file,

C: Character device file, p: Named pipe file,-: normal file.

The first paragraph rwx, which represents the owner's permission.

The second paragraph r-x, which represents the permissions of the group.

The third paragraph, R-x, represents the permissions (other users) that are not or are not part of the above users.

Root has super privileges.

The tux here represents the owner, the system represents the group, the subsequent array is the file size, followed by the last open time, and finally the file name.

A few points to note:

1, if there is no class execution permission in the Permissions table, then root does not have executable permissions.

2, for ordinary files, have execute permission, there must be read permission.

3, for the directory R representative can view the current directory, W represents the files that can modify this directory, x represents the access to this directory.

4, there is no permission to this file, but there is a directory of permissions, can change? You can delete it and build a file with the same name, but the i-number may be the same or different.

Above.

Linux Learning Notes---some interesting commands

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.