Linux Common Commands Summary--ln

Source: Internet
Author: User

1. Function: Link a file or folder to another file or folder. Links are broken down into hard links and soft links, and hard links can be viewed as a single entry with multiple accesses to a file, and soft links as shortcuts.

2. Usage: ln [option] source file or directory destination file or directory

3. Parameters:

-P,--physical hard links

-S,--symbolic soft link

4. Example

Example 1: Creating a hard link and a soft link, respectively

[email protected] test]# echo "Today is Tuesday" >>test_1.txt

[email protected] test]# cat Test_1.txt

Today is Tuesday

[email protected] test]# ls-lh

Total dosage 4.0K

-rw-r--r--1 root root 17 May 17:36 Test_1.txt

[email protected] test]# ln test_1.txt hard_test.txt

[email protected] test]# ls-lh

Total dosage 8.0K

-rw-r--r--2 root root 17 May 17:36 Hard_test.txt

-rw-r--r--2 root root 17 May 17:36 Test_1.txt

[email protected] test]# ln-s test_1.txt soft_test.txt

[email protected] test]# ls-lh

Total dosage 8.0K

-rw-r--r--2 root root 17 May 17:36 Hard_test.txt

lrwxrwxrwx 1 root root 10 May 17:38 Soft_test.txt-Test_1.txt

-rw-r--r--2 root root 17 May 17:36 Test_1.txt

Example 2: After deleting test_1.txt, the hard-linked files can be accessed normally, and the contents are the same as the contents of the source file, the file can be accessed normally, but the file color of the soft link is changed.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/80/32/wkiol1c66ipbsrrtaaalomw7ib0033.png "title=" Clipboard.png "alt=" Wkiol1c66ipbsrrtaaalomw7ib0033.png "/>


Linux Common Commands Summary--ln

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.