Difference Between Web Server and Web Client
Whenever you browse a website or use an online application, two main components work together…
A symbolic link (also called a soft link or symlink) is a special file that points to another file or directory. Think of it like a shortcut: when you open the link, the system follows it to the real target. Symlinks are useful for shorter paths, shared configs, version switching, and keeping multiple paths pointing to one location.
Linux supports two kinds of links:
Use the ln command with the -s option:
ln -s <target> <link_name>
<target>: the real file or directory you want to point to
<link_name>: the name (path) of the symlink you want to create
Example
ln -s /opt/app/current/config.yaml ~/config.yaml
This creates a symlink ~/config.yaml that points to /opt/app/current/config.yaml.
Tip: Prefer relative targets when linking inside the same project tree:
ln -s ../bin/tool ./tool
Relative links remain valid if the whole folder is moved elsewhere.
Common options you’ll actually use:
Examples:
# Basic symlink
ln -s /var/www/html/index.html ~/index.html
# Verbose output
ln -sv /usr/local/bin/mytool /usr/bin/mytool
# Force overwrite an existing link or file
ln -sfn /etc/nginx/sites-available/app.conf /etc/nginx/sites-enabled/app.conf
You create directory symlinks the same way:
ln -s /data/backups /mnt/backups
Now /mnt/backups behaves like a pointer to /data/backups.
Version switching example:
ln -sfn /opt/node-v20 /opt/node
# /opt/node now points to /opt/node-v20
If the link already exists and you want to repoint it:
ln -sfn <new_target> <existing_link>
Example:
ln -sfn /opt/app/releases/2026-02-11 /opt/app/current
Removing a symlink does not delete the target. It only removes the pointer.
Use any of the following:
# Remove by name
rm mylink
# Unlink explicitly
unlink mylink
# Remove a symlink to a directory (don’t use a trailing slash)
rm /path/to/linkdir
# Correct
rm link_to_dir
# Avoid (may attempt to remove directory contents)
rm -r link_to_dir/
List with details:
ls -l
# output example: mylink -> /real/path/target
readlink mylink
readlink -f mylink # prints the absolute, canonical path
find /path -xtype l
# or to list only broken links:
find /path -L -type l
Built‑in help and manual pages provide the authoritative reference:
ln --help
man ln
Symlinks are a simple, powerful way to redirect paths, share resources, and manage versions without copying files. Use ln -s to create them, -sfn to safely overwrite them, and rm or unlink to remove them. Verify with ls -l or readlink. With a few careful habits (relative paths, no trailing slashes, and the right flags, you’ll keep your links reliable and your filesystem tidy.
Learn how to redirect stdout and stderr to a file in Bash, capture logs efficiently, debug faster, and streamline script output management.
Explore more hosting insights, tips and industry updates.
Whenever you browse a website or use an online application, two main components work together…
This tutorial outlines the steps for removing the cPanel Cache Manager from your server, which…
In this article, we will explain how to change your server’s hostname with the help…