Skip to content

Commit

Permalink
feat(posts): update "How to create a symlink"
Browse files Browse the repository at this point in the history
Post: 2016-09-16-create-symlink.md

Add realpath and improve instructions
  • Loading branch information
remarkablemark authored Jun 14, 2024
1 parent b792d10 commit ff6aaf6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions _posts/2016/2016-09-16-create-symlink.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
layout: post
title: How to create a symlink
date: 2016-09-16 22:29:00
excerpt: How to create a symbolic link or symlink.
categories: symlink symbolic link
updated: 2024-06-14 11:50:59
excerpt: How to create a symbolic link (symlink).
categories: symlink symbolic link bash
---

Create a **symlink** (symbolic link) to reference another file or directory:
Create a **symlink** (symbolic link) to alias another file or directory:

```sh
ln -s <source> <destination>
```

## Example
## Usage

Given the following directory structure:
Given the directory structure:

```
.
Expand All @@ -29,7 +30,7 @@ You can create a symlink like below:
ln -s path/to/source path/to/target
```

You will now have the following:
You'll now have the following:

```
.
Expand Down Expand Up @@ -61,9 +62,15 @@ Also, if you don't want the symlink to be relative, then make the path absolute:
ln -s "$(pwd)/path/to/source" path/to/target
```

Or use `realpath`:

```sh
ln -s "$(realpath path/to/source)" path/to/target
```

This ensures the symlink still points to the expected location even if it's moved.

For more information, check out the manual page for the `ln` command:
Check out the manual page for more information:

```sh
man ln
Expand Down

0 comments on commit ff6aaf6

Please sign in to comment.