October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Create and Manage Symbolic Links on a Linux Server

A practical Linux server guide to symbolic links: create file and directory links, understand relative versus absolute targets, switch release pointers, diagnose dangling links, and remove symlinks safely.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use ln -s TARGET LINK_NAME to create a symbolic link: the target comes first, and the new link name comes second. A symlink stores a pathname rather than file data, so you can redirect a service, release directory, or configuration path without copying content. The sections below show how to choose absolute or relative targets, verify what a link resolves to, switch links during deployments, remove links without deleting their targets, and repair dangling links.

What a symbolic link is

A symbolic link, or symlink, is a directory entry containing a pathname reference. Programs that open the link normally continue through that pathname to the referenced file or directory. The link itself is not a second copy of the target’s bytes and does not become a hard link to the target’s inode.

As an Amazon Associate I earn from qualifying purchases.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Because the stored value is a pathname, a symlink can become dangling. That happens when the referenced pathname no longer resolves, for example after a file is renamed, a release directory is removed, or a mount is unavailable. GNU Coreutils documents that there are no restrictions against creating dangling symbolic links; creation can succeed even when the target does not yet exist.

Two details determine most symlink behavior:

  • The operand order: ln -s TARGET LINK_NAME reads as “make LINK_NAME point to TARGET.”
  • The target form: an absolute target begins at /; a relative target is interpreted from the directory that contains the link.

Before you create a link

Decide what path users or a service should access, where the link entry will live, and whether that path will move as a unit. You need write permission for the parent directory that will contain the new link. If the path is under a protected location, run the command with the appropriate administrative account rather than changing broad permissions.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Quote paths that contain spaces, wildcard characters, or shell metacharacters. The shell expands unquoted wildcard patterns before ln receives them, which can produce a link with an unintended target or destination.

  • Check the parent directory with ls -ld PARENT.
  • Check whether a destination name already exists before creating the link.
  • For a service configuration, validate the link before reloading or restarting the service.
  • Treat a directory symlink as a control-plane change: every path below it can switch to another subtree.

Create a symlink to a file

Basic file-link procedure

  1. Choose the pathname that should be referenced and the pathname users will use.
  2. Run ln -s with the target first and link name second.
  3. Inspect the resulting entry with ls -l and, when needed, readlink.
ln -s /etc/nginx/sites-available/example.conf /etc/nginx/sites-enabled/example.conf
ls -l /etc/nginx/sites-enabled/example.conf
readlink /etc/nginx/sites-enabled/example.conf

The link in this example stores /etc/nginx/sites-available/example.conf. Accessing /etc/nginx/sites-enabled/example.conf follows that stored pathname. Confirm the result before asking the web server or another daemon to reload its configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If the destination name already exists, ordinary ln behavior is conservative: it normally refuses to replace it. Do not assume that a failed command left the old entry unchanged without checking; inspect the path and its parent directory.

Create a symlink to a directory

The syntax is the same for a directory pathname. The link entry is a single name, but traversing it exposes the entire target subtree.

ln -s /srv/releases/app-2026.10 /srv/app
ls -ld /srv/app
readlink /srv/app

After this command, applications using /srv/app reach the selected release directory. A directory link is useful for a stable application path, but changing it can redirect reads, writes, logs, and executable files at once. Establish an ownership and change-control expectation before switching a production directory link.

Relative and absolute symlinks

The choice is about how the target pathname is interpreted when the link is used. Neither form is universally superior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Property Relative target Absolute target
Resolution base The directory containing the link The filesystem root, /
Example target text ../releases/app-2026.10 /srv/releases/app-2026.10
Moving the containing tree Can continue to work when the linked tree and target move together Still names the original absolute pathname
Moving or mounting the tree under another prefix Usually avoids dependence on that prefix May point outside the mounted or relocated tree
Human readability Requires reasoning from the link’s parent directory Immediately shows a complete pathname
Typical risk A mistaken number of .. components points somewhere unexpected The fixed pathname is absent or means something different on another host

When a relative link is appropriate

Use a relative target when a directory tree is intended to be portable as a unit, such as a self-contained web tree with sibling release directories. The target is resolved from the directory that contains the link, not from the shell’s current working directory at the time someone later follows it.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
cd /srv/www/current-parent
ln -s ../releases/app-2026.10 current
readlink /srv/www/current

Here, ../releases/app-2026.10 is interpreted relative to /srv/www/current-parent, the parent directory of current. Running a command from another directory later does not change that interpretation.

GNU ln also provides --relative (or -r) to calculate a relative target from canonicalized paths. This is useful when manually counting parent-directory components would be error-prone.

ln -s --relative /srv/releases/app-2026.10 /srv/www/current

Review the generated link text after using this option. Canonicalization can expose missing components or resolve paths differently from what you intended if the input names are not the tree you meant to package.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When an absolute link is appropriate

An absolute target is unambiguous on the host where it is created. GNU documentation notes that an absolute symlink continues to point to the same pathname even if the directory containing the link is moved.

ln -s /srv/releases/app-2026.10 /srv/www/current

This form is often easier to audit in configuration output because the complete destination is visible. It is a poor fit when the same directory tree may be mounted below a different prefix, copied into a chroot-like environment, or shared across machines whose filesystem layouts differ. In those cases the link can remain syntactically valid while resolving to the wrong place or to nothing.

Inspect the stored link and its destination

Use a command that answers the specific question you have. Looking at the link entry and resolving its destination are different operations.

Command What it shows Useful interpretation
ls -l LINK The directory listing, including the stored target after -> Confirms that the entry is a symlink and displays its text
readlink LINK The exact pathname text stored in the symlink Distinguishes relative text from an absolute pathname without following it
readlink -f LINK A canonicalized, resolved destination Shows where the complete path resolves; failure signals a missing component or broken link
realpath LINK The canonical destination pathname Useful in scripts or diagnostics that need a normalized result
ls -l /srv/www/current
readlink /srv/www/current
readlink -f /srv/www/current
realpath /srv/www/current

readlink alone does not prove that the target exists; it prints the stored text. Canonicalizing commands attempt to follow the path, so a nonzero result or no usable pathname is an important indication that a component is absent or inaccessible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Test symlinks in shell scripts

Use test -L when you need to distinguish a symlink entry from an ordinary file. Then use test -e to determine whether the link currently resolves to an existing object.

if test -L "$link"; then
  printf 'link text: %sn' "$(readlink -- "$link")"
  if test -e "$link"; then
    printf 'target resolvesn'
  else
    printf 'dangling linkn' >&2
  fi
fi

A dangling link is not an invalid symlink object. It is an entry whose stored pathname cannot currently be resolved. Keeping that distinction in deployment and monitoring scripts prevents a missing release from being mistaken for a malformed link.

Change a symlink without deleting the target

Understand replacement behavior

To point a stable name at another release, you replace the link entry; you do not edit the target directory. GNU ln normally refuses to replace an existing destination. Its replacement-related modes have different operational consequences:

Option Behavior Use with care because
-f Unconditionally remove the existing destination entry and create the new link An unexpected path can be replaced without an operator prompt
-i Ask before replacing an existing destination Automation can stall waiting for input, but it is useful during a supervised change
-b Back up an existing destination before replacement The backup itself must be named, retained, and managed deliberately
-T or --no-target-directory Treat the destination operand as the link entry, not as a directory into which to place a link It matters when the destination name is itself a symlink to a directory

Controlled release switch

For a release pointer, inspect the current resolution, replace the intended entry, and verify the new resolution immediately.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
readlink -f /srv/www/current || true
ln -sfn /srv/releases/app-2026.11 /srv/www/current
readlink -f /srv/www/current

The -n component prevents a symlink-to-directory destination from being treated like a directory in implementations that support that behavior; together with -f, this common GNU form is intended to replace the link entry. Use it only after confirming that /srv/www/current is the expected symlink or destination. If the path could have been replaced by a real directory or by an attacker-controlled link, stop and inspect instead of forcing the operation.

During a change window, use the interactive form when an operator must approve the replacement:

ln -sni /srv/releases/app-2026.11 /srv/www/current

Use a backup mode when retaining the previous entry is part of your rollback procedure, and document where that backup will appear. A backup of a symlink entry does not preserve or duplicate the target directory; it preserves the prior directory entry so you can examine or restore it.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

After switching, validate both the link and the application-level configuration before reloading a service. A link can resolve successfully while the selected release still lacks a required file or has incompatible configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remove a symlink safely

Remove the link name, not the object it references:

rm -- /srv/www/current

or:

unlink -- /srv/www/current

These commands remove the directory entry for the symlink. They do not remove the referenced file or directory. Verify the entry with ls -l first, especially when a directory link is involved. Do not add a recursive option merely because the link points to a directory; recursive removal is for traversing real directory contents and is unnecessary for deleting the link entry.

After removal, check the link path and, if the target is important, check the target path separately. The target can remain available to other names even though the symlink no longer provides access through its former pathname.

Find and repair dangling links

Find links whose targets do not resolve

find /srv/www -xtype l -print

The -xtype l test selects symbolic links whose referenced object cannot be found through the specified path. Limit the search to a deliberate scope; running it from a broad root can produce entries owned by unrelated services or users.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Classify each result before changing it

  1. Read the stored pathname with readlink -- LINK.
  2. Resolve it with readlink -f -- LINK or realpath -- LINK to identify the missing component.
  3. Check whether the target was renamed, a release was intentionally retired, or a mount is temporarily unavailable.
  4. Recreate the link with the corrected target, restore the expected target path, or remove the stale link according to the service’s ownership and change process.
  5. Re-run the search and validate the consuming application.

Do not bulk-delete every result. Some dangling links are deliberately created ahead of a deployment or are valid only when a particular filesystem is mounted. Confirm path scope and ownership before repair.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

“File exists” from ln

The destination name is already present. Inspect it with ls -ld DESTINATION and determine whether it is the expected symlink, a real file, or a real directory. For an approved replacement, choose interactive, backup, or force behavior intentionally rather than adding -f reflexively.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

The link appears correct but the application cannot open it

Compare readlink output with readlink -f or realpath. A relative target may be calculated from the wrong parent directory, or an absolute target may not exist in the service’s mount namespace or filesystem layout. Check every parent component and the service’s own access permissions.

A relative link broke after a directory move

Relative resolution depends on the link’s containing directory. If the link and target were not moved together, the same stored text can lead somewhere different. Recreate the link from its new parent or convert it to an absolute target if the destination is intentionally fixed.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An absolute link broke after a mount or relocation

Absolute resolution starts at /. If the tree is now exposed below another prefix, the old pathname may not exist there. Use a relative link when the target should travel with the tree, or recreate the absolute link for the host’s actual layout.

A directory replacement affected more paths than expected

A directory symlink redirects an entire subtree. Inspect the current and new destinations with readlink -f, identify writers as well as readers, and switch only during a controlled change. If the operation was forced against an unexpected destination, stop and review the directory entry and any backup before attempting another replacement.

Deployment and administration checklist

  • Write the target and link name explicitly; remember that the target is the first operand.
  • Choose relative links for trees that should move together and absolute links for a deliberately fixed host pathname.
  • Inspect the existing destination before replacement.
  • Use --relative when GNU ln should calculate a relative path, then inspect the generated text.
  • Select -i, -b, or -f according to the change procedure; do not treat them as interchangeable.
  • Use -T or --no-target-directory when the destination must be replaced as a link entry rather than traversed as a directory.
  • Resolve the link after creation or replacement and test the application before reloading a service.
  • Remove only the symlink entry with rm -- LINK or unlink -- LINK; never add recursion just because the target is a directory.
  • Search for dangling links with a scoped find ... -xtype l command and review each result before repair.

GNU and non-GNU portability

The option behavior described here follows GNU Coreutils ln documentation, version 9.11, and the Linux ln(1) manual. Long options such as --relative, --no-target-directory, and the exact interactions of force and backup modes can differ on non-GNU Unix systems. Before placing one of these commands in a portable script, run ln --help and consult the local manual page. The basic symbolic-link operation and the target-first, link-name-second operand order remain the starting point, but scripts should not assume every GNU extension exists elsewhere.

Minimal verification sequence

For a single change, this compact sequence gives you the essential checks without following the target during creation:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ln -s TARGET LINK_NAME
ls -l -- LINK_NAME
readlink -- LINK_NAME
readlink -f -- LINK_NAME

If the final command resolves to the intended canonical pathname, the link is usable at that moment. If it fails, keep the link entry for investigation or remove it deliberately; do not infer success merely because ln accepted the stored pathname.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.