“ln” is a command to create a file link. Although you can create a hard link with “in file name link name”, it is more general to use a “-s” option and create a symbolic link as “ln -s file name link name”.
With “ln -s”, you can create a “symbolic link” of the file. A symbolic link is a so-colled “alias” of a file, giving a different name to a long file name or making it easier to handle a file in a place where it is difficult to specify a path name.
[vagrant@localhost symbolic]$ ls
mylist01.txt mylist02.txt
The “-l” option is a frequently used command. “L” means a long format. Just as long as it displays details, it becomes landscape.
[vagrant@localhost symbolic]$ ls -l
合計 0
-rw-rw-r– 1 vagrant vagrant 0 1月 27 16:43 2019 mylist01.txt
-rw-rw-r– 1 vagrant vagrant 0 1月 27 16:43 2019 mylist02.txt
Create a symbolic link named “latest” in “mylist02.txt” with “ln -s” command.
[vagrant@localhost symbolic]$ ln -s mylist02.txt latest
[vagrant@localhost symbolic]$ ls -l
合計 0
lrwxrwxrwx 1 vagrant vagrant 12 1月 27 16:47 2019 latest -> mylist02.txt
-rw-rw-r– 1 vagrant vagrant 0 1月 27 16:43 2019 mylist01.txt
-rw-rw-r– 1 vagrant vagrant 0 1月 27 16:43 2019 mylist02.txt
[vagrant@localhost symbolic]$ ls -l
合計 0
lrwxrwxrwx 1 vagrant vagrant 12 1月 27 16:47 2019 latest -> mylist02.txt
-rw-rw-r– 1 vagrant vagrant 0 1月 27 16:43 2019 mylist01.txt
-rw-rw-r– 1 vagrant vagrant 0 1月 27 16:43 2019 mylist02.txt
-rw-rw-r– 1 vagrant vagrant 0 1月 27 16:50 2019 mylist03.txt
[vagrant@localhost symbolic]$ ln -sb text03.txt latest
[vagrant@localhost symbolic]$ ls -l
合計 0
lrwxrwxrwx 1 vagrant vagrant 10 1月 27 16:51 2019 latest -> text03.txt
lrwxrwxrwx 1 vagrant vagrant 12 1月 27 16:47 2019 latest~ -> mylist02.txt
-rw-rw-r– 1 vagrant vagrant 0 1月 27 16:43 2019 mylist01.txt
-rw-rw-r– 1 vagrant vagrant 0 1月 27 16:43 2019 mylist02.txt
-rw-rw-r– 1 vagrant vagrant 0 1月 27 16:50 2019 mylist03.txt
In “ln -s” you can also create a link to nonexistent file.
[vagrant@localhost symbolic]$ ls
backupdir latest latest~ mylist01.txt mylist02.txt mylist03.txt
[vagrant@localhost symbolic]$ cd backupdir
[vagrant@localhost backupdir]$ ln -s ../.bashrc bashrc0518
[vagrant@localhost backupdir]$ ls
bashrc0518