banner



How To Create The Soft Link In Linux

Symbolic links are a very important admin tool to use in Linux. Jack Wallen tells you why and how to create such links with ease.

Symbolic links (also called a soft link) are a very important tool to understand in Linux. These are special files that point to other files, similar to shortcuts in Windows or aliases in macOS. Symbolic links do not contain the data, but rather, a pointer to the actual file that does contain the data.

By using symbolic links, you make it possible to more easily access other files that might reside in complicated directory paths or are required for certain services, such as enabling virtual host configurations in NGINX. In fact, without knowing how to use links, you'll find some Linux administration tasks quite difficult.

Let me show you how to use this feature.

SEE: Linux file and directory management commands  (TechRepublic Premium)

The idea behind creating a symbolic link is that you're creating a link from the source to the destination. You must remember this, as it's how the command is issued. The basic command for creating symbolic links is:

ln -s original link

 We use the -s option to inform the ln command we're creating a symbolic link. The original is the location of the file that contains the data and the link is the symbolic link.

Let's say you are using NGINX and you've created the mysite.conf virtual host configuration in /etc/nginx/sites-available. To enable that new site, you must create a symbolic link from /etc/nginx/sites-available to /etc/nginx/sites-enabled/mysite.conf. Because this also requires admin access, you will have to use sudo to make it work.

To do that, you issue the command:

sudo ln -s /etc/nginx/sites-available/mysite.conf /etc/nginx/sites-enabled/mysite.conf

 The important thing to remember here is the order: original/link.

There are two ways to remove a link. You can use the unlink command, as in:

unlink link

Where link is the name of the link. Or, you can simply remove the link with the rm command, as in rm link (where link is the name of the link file).

And that's all there is to creating symbolic links in Linux. Enjoy that fresh linking power.

Subscribe to TechRepublic's How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Open Source Weekly Newsletter

You don't want to miss our tips, tutorials, and commentary on the Linux OS and open source applications. Delivered Tuesdays

Sign up today

Also see

  • How to become a developer: A cheat sheet (TechRepublic)

  • Kubernetes security guide (free PDF) (TechRepublic)

  • Could Microsoft be en route to dumping Windows in favor of Linux? (TechRepublic)

  • How open source-software transformed the business world (ZDNet)

  • Linux, Android, and more open source tech coverage (TechRepublic on Flipboard)

linuxhero2-1.jpg

Image: iStockPhoto/TimArbaev

How To Create The Soft Link In Linux

Source: https://www.techrepublic.com/article/linux-101-how-to-create-symbolic-links-in-linux/

Posted by: serranopentagess.blogspot.com

0 Response to "How To Create The Soft Link In Linux"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel