Junior — Middle
Explain the principle of symbolic links in Linux and their purpose.
sobes.tech AI
Answer from AI
A symbolic link (symlink) in Linux is a special file that contains the path to another file or directory. It acts as a shortcut, allowing access to the object by a different name or in a different location within the filesystem.
Working principle:
- Symlink stores the path to the target file or directory.
- When accessing the link, the system redirects the request to the target object.
- If the target file is deleted, the link becomes 'broken' and no longer works.
Purpose:
- Convenience in organizing the filesystem.
- Creating alternative paths to files.
- Ensuring compatibility and simplifying updates.
Creating a symbolic link:
ln -s /path/to/original /path/to/link
For example, ln -s /usr/local/bin/python3 /usr/bin/python creates a link /usr/bin/python pointing to /usr/local/bin/python3.