Linux commands: LN link files--hard links, symbolic links (soft links)

Source: Internet
Author: User
Tags parent directory

LN Introduction to Commands:

A hard link is created by default, and a symbolic link is created when you use-S.

1 . Command format:

ln [option] Original file link file path preferably with absolute path

ln original file link file without parameter means create hardware link

-s means creating a soft link

Option (optional):

-S Create soft links

-V Displays the creation process.

Hard Links:

1 , can only create files, can not be applied to the directory;

2 , cannot cross file system;

3 , creating a hard link increases the number of times the file is linked;       

Symbolic links (soft links):

1 , can be applied to the directory;

2 , can cross file system;

3 , will not increase the number of links to linked files;

4 , the size of the specified path contains the number of characters;

2 . Command function:

Used to create a linked file that must exist for each specified target when a hard link is created. A symbolic link can point to any location and, when the link resolves correctly, resolves it to a link associated with its parent directory.

3 . Command parameters:

-S Create soft links

-V Displays the creation process.

4 . Command instance:

1. Create a hard link:

ln ABC/TEST/ABC2 The ABC file under the current directory, creating a hard link to the/test directory and named ABC2

Create a hard link whose inode number is consistent

[Email protected] test2]# LN ABC/TEST/ABC2

[Email protected] test2]# cd/test

[Email protected] test]# Ls-li ABC2

2996-rw-r--r--. 2 root root 884 October 15:27 ABC2

[Email protected] test2]# Ls-li ABC

2996-rw-r--r--. 2 root root 884 October 15:27 ABC

2. Create a soft link:

Ln-s/TEST2/ABC2/TEST/ABC3 Create software ABC3 point to ABC2

[Email protected] test2]# ln-s/TEST2/ABC2/TEST/ABC3

3003 lrwxrwxrwx. 1 root root 11 October 15:36 ABC3-/TEST2/ABC2


This article is from the "Learn Linux history" blog, please be sure to keep this source http://woyaoxuelinux.blog.51cto.com/5663865/1866782

Linux commands: LN link files--hard links, symbolic links (soft links)

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.