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.
[email protected]:/tmp# ./hello.sh
hello world
[email protected]:/tmp# ln -s /tmp/hello.sh /bin/shello
[email protected]:/tmp# shello
hello world
[email protected]:/tmp# ln /tmp/hello.sh /bin/hhello
[email protected]:/tmp# hhello
hello world
[email protected]:/tmp# rm -rf /bin/shello
[email protected]:/tmp# shello
bash: /bin/shello: No such file or directory
[email protected]:/tmp# hhello
hello world
[email protected]:/tmp# rm -rf /bin/hhello
[email protected]:/tmp# ./hello.sh
hello world
[email protected]:/tmp#
Read More:
- Dell Error Code for Failed Hard Disk
- Python environment error, bad interpreter: there is no file or directory
- The Python DOM method iterates over all the XML in a folder
- Python: SVN deletes files on local and remote repositories
- [CUDA Environment] Python Pytorch Error: CudaSetupArgument
- [Solved] RuntimeError: unexpected EOF, expected 73963 more bytes. The file might be corrupted.
- [Solved] TypeError: not all arguments converted during string formatting
- [Solved] Mac ffmpeg Install Error: filenotfounderror: [errno 2] no such file or directory: ‘ffmpeg’: ‘ffmpeg’
- [Solved] awtk scons Error: unsupported pickle protocol: 4
- Linux Fatal Python error: Py_Initialize Unable to get the locale encoding
- Python Error: mongod: error while loading shared libraries: libcrypto.so.1.1
- [Solved] Pycharm Use pip to install package error: no such option –build-dir
- [Solved] ValueError: Connection error, and we cannot find the requested files in the cached path…
- [Solved] HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/saved_model
- Python 3 uses the relative path import module
- How to Solve Yolox Training C Disk Full Issue
- Httprunner output assure Report
- Tesseract OCR text recognition using tess4j encapsulation
- [Solved] Sudo doesn‘t work: “/etc/sudoers is owned by uid 1000, should be 0”
- An error is reported in the requirements code of the generated project