How to create a link in the Linux

1
ln -s [file] [the link]

For example, now you have a file called the t1.txt, then you
wants to make a link called t2 to the t1.txt
Then you can do as follow

1
ln -s t1.txt t2

cat t2 will have the same effect as the cat t1.txt

Then we can use the ls command to check the l2

1
2
3
4
> ls -l t1.txt
-rw-rw-r-- 1 halfstar halfstar 7 3月 30 23:03 t1.txt
> ls -l t2
lrwxrwxrwx 1 halfstar halfstar 6 3月 30 23:04 t2 -> t1.txt

The link do not same as the t1 totaly, and the -> means what it point to.

If the link aready exist, it will be error if you try to link it to a
different file.

If you still wants to do it. Just add the -f to the command.

1
ln -sf t3.txt t2

Whether the unlink or the rm is ok.