How to Symlink a file in Linux?
Step 1: To symlink a file, first, we need to create a file named “gfgfile”
touch gfgfile
`touch` command is used to create a file.
Step 2: For creating a symlink file, we can use the command as:
ln -s [original file] [symbolic link file]
- ln: make a link between files.
- -s: create a symbolic link of a file instead of a hard link.
Step 3: As you can see, ‘gfgsym’ indicates an original file location.
ls -la
`ls` command is used to list all the file and directories.
Step 4: You can access the information using the link file.
cat gfgsym
`cat` command is used to see the content inside a file.
How to Symlink a File in Linux
In Linux/UNIX, a symbolic link or soft link, also referred to as a symlink, is a useful tool for linking files or directories from different locations. Similar to a pointer in C programming, a symlink directs to the original file from an alternate location. The creation of symbolic links is facilitated by the ln command. However, it is important to note that a symlink will only function if the original file exists on the system. If the original file is accidentally deleted, the symlink file becomes unusable.