ln
The function is to establish a synchronous link for a certain file in another location.
The most commonly used parameter of this command is -s, the
specific usage is: ln -s Source file Target file
.
When the same file is used in different directories, there is no need to put a file that must be the same in every required directory, but only in a fixed directory, put the file, and then put it in other directories Use the ln command to link (link) it, and you don’t have to repeatedly take up disk space.
For example: ln -s /bin/hello.sh /usr/local/bin/hello
-s is the meaning of the code (symbolic).
There are two points to note here:
first, the ln command will keep every link file synchronized, that is, no matter where you change, other files will have the same changes;
second, the ln link There are two kinds of soft links and hard links.
Soft links are that ln -s src dst,
it will only generate a mirror image of a file in the location you selected, and will not occupy disk space.
Hard links ln src dst
, without the parameter -s, will be in the location you selected. Generate a file with the same size as the source file, whether it is a soft link or a hard link, the file keeps changing synchronously.
Deletion of a connection:
Direct rm dst
Example :rm /usr/local/bin/hello
If you use ls to view a directory, and find that some files have a @
symbol behind them, that is a file generated by the ln command, use the ls -l
command to view, and you can see the displayed link path.
root@ubuntu:/tmp# ./hello.sh
hello world
root@ubuntu:/tmp# ln -s /tmp/hello.sh /bin/shello
root@ubuntu:/tmp# shello
hello world
root@ubuntu:/tmp# ln /tmp/hello.sh /bin/hhello
root@ubuntu:/tmp# hhello
hello world
root@ubuntu:/tmp# rm -rf /bin/shello
root@ubuntu:/tmp# shello
bash: /bin/shello: No such file or directory
root@ubuntu:/tmp# hhello
hello world
root@ubuntu:/tmp# rm -rf /bin/hhello
root@ubuntu:/tmp# ./hello.sh
hello world
root@ubuntu:/tmp#
Read More:
- Python requests Error: ConnectionError: (‘Connection aborted.‘, error(104, ‘Connection reset by peer‘))
- [Solved] ValueError: Connection error, and we cannot find the requested files in the cached path…
- Here is the difference and connection of Torch. View (), Transpose (), and Permute ()
- [Solved] Python requests ConnectionError Error: connection aborted BadStatusLine
- Python Error: Failed to establish a new connection: [Errno -2] Name or service not known
- When sending HTTP request, python encountered: error 54, ‘connection reset by peer’ solution
- [Solved] Connection Error: couldn‘t reach http://raw.githubusercontent.com/huggingface/…
- [Solved] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection…
- Failed to establish a new connection: [winerror 10048] in the requests thread pool, the interface is called circularly to get the datagram error
- Pycharm WebSocket Error: Error: Connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
- Pychar can’t connect to Python console, but it can run. Py file, and Anaconda’s command line can run Python command
- Linux Fatal Python error: Py_Initialize Unable to get the locale encoding
- [Solved] PySide2 Failed to Create a Graphical Python Program
- [Solved] CONDA ENV create and run Error: F environment.yml under win10
- Python: How to Create an Automatic Recording Program
- [Solved] Anaconda create env error: ResolvePackageNotFound
- command ‘gcc’ failed with exit status 1 error while installing scrapy
- Python3 Fatal error in launcher: Unable to create process using ‘”‘
- [Solved] pip Fatal error in launcher: Unable to create process using
- Failed to Create New Environment Error: Collecting package metadata (current_repodata.json): failed.