Solaris soft link and hard link and common ls Parameters

Source: Internet
Author: User
I am studying Solaris recently. It is actually a cainiao. It is planned to take the scsa certification several months later. So I posted some learning experiences and studied them together. Maybe something is too pediatric. Sorry.

When learning about the directory inheritance structure of Solaris, everyone knows a lot about it. I will not elaborate on the functions of each directory. Through reading, I found a problem that I did not notice before: Soft link and hard link.

The link is the link. ln commands are used in UNIX and Linux systems. The parameter-S must be added to the soft link.
 
Before talking about soft and hard links, we need to mention the file storage method. In Solaris, the file storage method is composed of inode and data blocks (including directories, in Unix systems, all files ). Inode is a label. Each inode number corresponds to a data blocks. Each file is actually associated with the inode label to obtain the data content. The following briefly describes the file1 Association mode. The inode corresponding to file1 is 3561, and its content is stored in the corresponding data blocks.
File1
------
|Inode 3561|
------
|
| Data blocks |
|
------

Soft linkIn fact, it is like a pointer. For example, if the local file name is link1 and the corresponding inode is 1228, the content stored in data bloacks is a pointer to another file. For example, to point to another file, the value is file1 and the value of inode is 3561.

The soft link command is ln-s pathname target.
For example, the preceding command is ln-s link1 file1.

Hard LinkIt is quite different from soft links. A hard Link means that both files point to the same inode. So if the soft link deletes the link, the original file will not be affected, but if the original file is deleted, the link will become invalid because the target cannot be found. Since inode can be found in both files, deleting one of them has no effect on the other.

Inode is a key part of the entire file system, just like a pointer. In other words, inode is an entry.
When we use the LS command to view the directory structure, if we use the-l parameter, we will see a lot of details, such:
# Ls-l
Total 2
Drwxr-XR-x 77 root sys 4096 Sep 23 dir
-Rwxr-XR-x 1 user 10000 Sep 23 File

The preceding permissions should be clear and not detailed. The number that follows the permission indicates the number of hard links to the file and directory. In other words, there are several files pointing to this inode.
We can see inode by adding the parameter-I:
# Ls-il dir
21449 drwxr-XR-x 77 root sys 4096 Sep 23 dir

The number before the permission is inode.

It can be seen that a file has at least one hard link, while a directory has at least two hard links. One is the entry of the Directory itself, and the other is ". ", indicates the entry of the local directory in the directory. Therefore, each directory contains one more hard link, because the sub-directory ".." indicates the parent directory entry. You can try it.

The following lists common parameters and functions of the LS command:
Ls
-L display detailed parameters
-A: displays all files, including hidden files.
-L displays the target directory information of the soft link.
-I: Display inode
-R: displays information including inherited subdirectories.
-D is followed by the root directory name. Only the directory name and information are displayed, and information in the directory is not displayed.



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.