Linux commands (10) Create links between files or directories ln

Source: Internet
Author: User

Introduction to Commands

The ln command is used to connect files or directories, such as specifying more than two files or directories at the same time, and the final destination is a directory that already exists, and all of the previously specified files or directories are copied to the directory. If you specify multiple files or directories at the same time, and the last destination is a nonexistent directory, an error occurs. The ln command keeps the synchronization of none of the linked files, which means that as soon as you change one of them, the files in other places will change the same.

Common parameters
-b 每个已经存在的目标文件创建备份文件-d 允许系统管理者硬链接自己的目录-f 强行建立文件或目录的连接,不论文件或目录是否存在-i 覆盖既有文件之前先询问-n 把符号连接的目的目录视为一般文件-s 创建符号连接而不是硬链接-S 使用 -b 参数备份目标文件后,备份文件的结尾会加上一个备份字符串-v 显示命令的执行过程-t 在指定目录中创建链接-T 将链接名当做普通文件(在对目录进行符号链接时用到此项)

LN's links are soft links and hard links, and soft links only generate a linked file at the destination, which does not actually occupy disk space. Equivalent to Windows shortcuts. A hard link generates a file at the destination that is the same size as the source file, whether it is a soft link or a hard link, the files are synchronized, the soft links can be spanned, the hard links must be on the same file system, and the directory cannot be hard-linked, and the symbolic links can point to any location. Soft links are also called Symbolic links.

Instance

Create a soft link

ls -s  /data/ln/src /data/ln/dst

Create a hard link

ls  /data/ln/src  /data/ln/dst_hard

The content of the soft link does not exist after the source file is deleted, and the contents of the hard-link file still exist.

Make a connection to all files and directories in a directory

ls -s  /data/ln/* /data/ln2

Linux commands (10) Create links between files or directories 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.