Advanced Standard

How to create and manage symbolic links in Linux

By Angus Published 3 March 2026 Updated 9 March 2026 4 min read

Symbolic links let you reference files and directories from multiple locations without duplicating data. They act as pointers that redirect to the original file or folder, which makes them useful for organising complex directory structures and maintaining backwards compatibility when you move files.

You will create symbolic links using the ln command, verify they point to the correct target and remove them when no longer needed.

Before you begin

  • You need SSH access to your Linux server.
  • You must have write permissions in the directory where you want to create the symbolic link.
  • The target file or directory should exist before creating the link.

Create a symbolic link to a directory

The ln command with the -s flag creates a symbolic link. The -s flag specifies a soft link rather than a hard link, which allows the link to point to directories and cross filesystem boundaries.

  1. Connect to your server via SSH.
    Open your terminal and connect using your server credentials.
  2. Navigate to the location where you want to create the link.
    Use the cd command to move to the directory that will contain the symbolic link. For example, cd /var/www moves you to the web root directory.
  3. Create the symbolic link.
    Run the following command, replacing the paths with your actual source and destination:
ln -s /path/to/target/directory /path/to/link-name

For example, to create a link called docs in your home directory that points to /usr/share/documentation, you would run:

ln -s /usr/share/documentation ~/docs
  1. Verify the link was created.
    Run ls -l in the directory containing your new link. Symbolic links display with an arrow showing the target path:
lrwxrwxrwx 1 user user 24 15 January 2025 docs -> /usr/share/documentation

The l at the start of the permissions string confirms this is a symbolic link. You can now access the target directory through the link name.

Change an existing symbolic link

Linux does not provide a direct command to modify a symbolic link’s target. You need to remove the existing link and create a new one pointing to the updated location.

  1. Remove the current symbolic link.
    Use the rm command followed by the link name. This removes only the link, not the target directory:
rm /path/to/link-name
  1. Create a new symbolic link.
    Run the ln -s command with the new target path and the same link name:
ln -s /path/to/new/target /path/to/link-name

The link now points to the new location. Any applications or scripts referencing the link name will automatically use the new target without requiring configuration changes.

Remove a symbolic link

Removing a symbolic link deletes only the pointer, not the target file or directory. This makes symbolic links safe to remove when you no longer need the reference.

  1. Delete the symbolic link.
    Use the rm command with the link path:
rm /path/to/link-name
  1. Confirm the link is removed.
    Run ls -l in the directory. The link name should no longer appear in the listing.

Do not add a trailing slash when removing directory symbolic links. Running rm /path/to/link-name/ may attempt to delete the target directory contents rather than the link itself.

Absolute paths versus relative paths

You can create symbolic links using absolute paths that start from the root directory or relative paths that reference locations from the current working directory. Absolute paths remain valid regardless of where you access the link from, which makes them more reliable for system-wide references. Relative paths work when the link and target maintain their positional relationship, but break if you move either component independently.

We recommend using absolute paths for symbolic links that will be accessed from multiple locations or referenced in automated scripts.

Wrapping up

You can now create symbolic links to reference directories from multiple locations, update link targets by removing and recreating them, and delete links without affecting the original files. Symbolic links reduce duplication and make directory structures more flexible.

Review your symbolic links periodically to confirm they still point to valid targets. Broken links occur when the target directory is moved or deleted. See our guides on Linux file permissions and SSH access for your server for related server management tasks.

Our Linux VPS hosting gives you full root access to create and manage symbolic links across your server environment.

Need more power?

Get scalable resources with our VPS hosting with root access and optional software.

Get VPS Hosting

Starting something new?

Perfect for websites and small businesses unlimited bandwidth with cPanel hosting.

Get cPanel Hosting