Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of the Linux basic command ln

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the usage of the Linux basic command ln". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the usage of the basic Linux command ln.

Ln

Creates a link for the specified directory or file, and if no link name is specified, a link with the same name as the source file is created. The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

Ln [OPTION]... [- T] TARGET LINK_NAME (1st form)

Ln [OPTION]... TARGET (2nd form)

Ln [OPTION]... TARGET... DIRECTORY (3rd form)

Ln [OPTION]... -t DIRECTORY TARGET... (4th form)

The first is to create a target link with the name LINK_NAME; the second is to create a link to a target in the current directory; and the third and fourth are to create a link to each target in the directory. Hard links are created by default, and symbolic links are created using "symbolic". When you create a hard link, each target must exist. Symbolic links can save arbitrary text; if parsed later, the relative link is interpreted according to its parent directory.

2. List of options

Option

Description

-- version

Display command version information

-- help

Show help documentation

-- backup [= CONTROL]

Create a backup for an existing link

-b

Same as "- backup", but with no parameters

-d |-F |-- directory

Allow superusers to create hard links

-f |-- force

Force to create, if it already exists, delete the original hard link

-I |-- interactive

Confirm whether to delete the destination file

-L |-- logical

Create a hard-linked association to a symbolic link

-n |-- no-dereference

Deal with the target of symlink with a directory as if it were a normal file

-P |-- physical

Create a hard link to a symbolic link

-s |-- symbolic

Create symbolic links

-S |-- suffix=SUFFIX

Override the usual backup suffix

-t |-- target-directory

Specify the directory where you want to create the link

-T |-- no-target-diretory

Use links as normal files

-v |-- verbose

Print the name of each linked file

3. Examples

1) create a hard link

[root@localhost weijie] # ln-v my.iso link1

"link" = > "my.iso"

2) create a symbolic link

[root@localhost weijie] # ln-v-s my.iso link2

"link2"-> "my.iso"

[root@localhost weijie] # ls-l

The total dosage is 1068

-rw-r--r-- 3 root root 358400 September 7 15:46 link1

Lrwxrwxrwx 1 root root 6 September 10 12:13 link2-> my.iso

Mkdir

If the directory does not exist, then create the directory.

The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

Mkdir [options] dir

2. List of options

Option

Description

-- version

Display command version information

-- help

Show help documentation

-m |-- mode=MODE

Set the permissions of the directory

-p |-- parents

When creating a multi-tier directory, if the parent directory does not exist, create the parent directory first

-v |-- vervose

Show execution process

3. Examples

1) create a directory with maximum permissions

[root@localhost weijie] # mkdir-m 777 test

[root@localhost weijie] # ls-l

Total consumption 360

-rw-r--r-- 1 root root 0 September 7 09:11 1.c

-rw-r--r-- 1 root root 358400 September 7 15:46 my.iso

Drwxrwxrwx 2 root root 4096 September 10 11:33 test

2) create a directory and its parent directory

[root@localhost weijie] # mkdir-v test01/test / / directory test01 does not exist and cannot create a test directory under it

Mkdir: unable to create directory "test01/test": there is no such file or directory

[root@localhost weijie] # mkdir-p-v test01/test / / use the option-p. When directory test01 does not exist, create test01 first.

Mkdir: directory "test01" has been created

Mkdir: directory "test01/test" has been created

You have new mail in / var/spool/mail/root

At this point, I believe you have a deeper understanding of "the use of the Linux basic command ln". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report