ln is an important command in the Linux system. It can establish links for files and maintain the synchronization of linked files. The following small series will introduce you to how to use the ln command under Linux, and learn more through examples.
1. Use the ln command to create a symbolic link to the file.
The symbolic link under Linux is similar to the shortcut for Windows.
Using the ls command, you can see that the newly created symbolic link has a separate inode, that is, the symbolic link will occupy an inode, but the actual content still points to the
source file. Block area.
# touch /tmp/file
# ls -lhi /tmp/file
3441 -rw-r--r-- 1 root root 0 Jan 1 00: 09 /tmp/file
#
# ln -fs /tmp/file /tmp/symbolic_link
# ls -lhi /tmp/symbolic_link
3647 lrwxrwxrwx 1 root root 9 Jan 1 00:10 /tmp/symbolic_link -" /tmp/file
#
2. Deleting the symbolic link file actually deletes the inode instead of Will affect the block area pointed to by the source file;
And if the source file is deleted, then the symbolic link file is basically useless.
# echo “link test” 》 /tmp/file
# cat /tmp/file
link test
#
# rm /tmp/symbolic_link
# cat /tmp/file
link test
#
# ln -fs /tmp/file /tmp /symbolic_link
#
# rm /tmp/file
# cat /tmp/symbolic_link
cat: can‘t open ’/tmp/Symbolic_link‘: No such file or directory
#
# ls -lhi /tmp/symbolic_link
7357 lrwxrwxrwx 1 root root 9 Jan 1 00:22 /tmp/symbolic_link -> /tmp/file
#
3. Use the ln command to create a hard link.
As you can see, creating a hard link uses the same inode and copies a block of the source file.
Previous12Next Total 2 Pages
In many cases, Linux is used as a server to allow computers on the Internet to acce
Use the cp command to copy files on Linux systems, but when you use the cp command
Because AWX does not support Debian system, Debian users feel very headache, in fact, as long as a s
In Linux, commands can be used to form dialog boxes. The dialog box formed by Linux command line is
How to delete git branches in batches in Linux system
Linux uses the chgrp command to modify the group to which the file belongs
Linux adds custom encryption algorithms to OpenSSL
Linux installation GBK/GB2312 program shows garbled how to do?
Linux compression of JPEG images through the command line
Linux configuration yum.conf method
How to develop JNDI in Linux Jetty environment
What should I do if Xmanager fails to connect after the Solaris system is installed?
Steps for creating RPM packages for Linux systems
Detailed analysis of the nine major problems that led to the failure of the reinstallation system
Win7 set the speed of the mouse skills
Can an xp 32-bit system support 4G memory?
How to make 32-bit win7 use 4G memory is no longer a lie
Win10 preview version 9901 confirmed the existence of "burst" dynamic tile?
Modify the registry to completely block Win 2003 security risks
Win8.1 upgrade Win10 system to 99% pop-up error code 8024031 failure reason and solution
How to install Win10 system to U disk