{"id":4967,"date":"2023-07-21T11:40:54","date_gmt":"2023-07-21T11:40:54","guid":{"rendered":"https:\/\/arzhost.com\/blogs\/?p=4967"},"modified":"2024-10-17T19:41:58","modified_gmt":"2024-10-17T14:41:58","slug":"create-symbolic-links-in-linux","status":"publish","type":"post","link":"https:\/\/arzhost.com\/blogs\/create-symbolic-links-in-linux\/","title":{"rendered":"Create Symbolic Links in Linux: A Step-by-Step Guide"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/arzhost.com\/blogs\/create-symbolic-links-in-linux\/#Introduction_Symbolic_Links_in_Linux_and_What_They_are_Important\" >Introduction: Symbolic Links in Linux and What They are Important<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/arzhost.com\/blogs\/create-symbolic-links-in-linux\/#Learn_How_to_Create_Symbolic_Links_in_Linux\" >Learn How to Create Symbolic Links in Linux.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/arzhost.com\/blogs\/create-symbolic-links-in-linux\/#Ln_Command_to_Create_Symbolic_Links\" >Ln Command to Create Symbolic Links<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/arzhost.com\/blogs\/create-symbolic-links-in-linux\/#Create_a_Symbolic_Link_to_the_Linux_Directory\" >Create a Symbolic Link to the Linux Directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/arzhost.com\/blogs\/create-symbolic-links-in-linux\/#Overwrite_Symbolic_Links_Using_Force\" >Overwrite Symbolic Links Using Force<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/arzhost.com\/blogs\/create-symbolic-links-in-linux\/#Link_Removal_or_Removal\" >Link Removal or Removal<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/arzhost.com\/blogs\/create-symbolic-links-in-linux\/#Supercharge_Your_WordPress_Hosting%E2%80%94Sign_Up_Enjoy_Discounts\" >Supercharge Your WordPress Hosting\u2014Sign Up &amp; Enjoy Discounts!<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/arzhost.com\/blogs\/create-symbolic-links-in-linux\/#Hard_Links_vs_Soft_Links\" >Hard Links vs. Soft Links<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/arzhost.com\/blogs\/create-symbolic-links-in-linux\/#1_Soft_Symbolic_Links\" >1: Soft (Symbolic) Links<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/arzhost.com\/blogs\/create-symbolic-links-in-linux\/#2_Hard_Links\" >2: Hard Links<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/arzhost.com\/blogs\/create-symbolic-links-in-linux\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Introduction_Symbolic_Links_in_Linux_and_What_They_are_Important\"><\/span>Introduction: Symbolic Links in Linux and What They are Important<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>A file or folder is referenced via a link. In <a href=\"https:\/\/www.linux.org\/\" target=\"_blank\" rel=\"noopener\"><strong>Linux<\/strong><\/a>, we see <span style=\"color: #000000;\"><strong>How to Create Symbolic Links in Linux<\/strong><\/span>? symbolic links are used to organize and manage files.<\/p>\n\n\n\n<p>For Related Articles and Guides, Subscribe to our <a href=\"https:\/\/arzhost.com\/blogs\/\"><strong>Blog<\/strong><\/a> and get the latest news on Technology!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Learn_How_to_Create_Symbolic_Links_in_Linux\"><\/span><u>Learn How to Create Symbolic Links in Linux. <\/u><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><u>with the ln command by reading this manual.<\/u><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>A Linux-running computer<\/strong><\/li>\n\n\n\n<li><strong>Access to the command line or terminal window (Activities > Search > type Terminal)<\/strong><\/li>\n\n\n\n<li><strong>A user account with root or sudo rights (optional) (needed to access certain protected files and directories).<\/strong><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Ln_Command_to_Create_Symbolic_Links\"><\/span><strong>Ln Command to Create Symbolic Links<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><u>Open a terminal window and type the following command to use the ln function:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ln [-sf] [source] [destination]<\/li>\n\n\n\n<li>The ln command creates a hard link by default.<\/li>\n\n\n\n<li>To build a soft (symbolic) link, use the -s option.<\/li>\n\n\n\n<li>The program will be forced to overwrite an existing file if the -f option is used.<\/li>\n\n\n\n<li>The file or directory is linked to its source.<\/li>\n\n\n\n<li>The destination specifies where the link will be saved; if this field is left empty, the symlink will be saved in the current working directory.<\/li>\n<\/ul>\n\n\n\n<p><u>Make a symbolic connection, for instance, with:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>test file.txt, link file.txt, and ln -s<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>This makes test file.txt the target of a symbolic link created by link file.txt.<\/u><\/p>\n\n\n\n<p><u>Use the ls command to see if the symbolic has been created:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>link file.txt, ls -l<\/code><\/li>\n<\/ul>\n\n\n\n<p><strong>Related Article: <a href=\"https:\/\/arzhost.com\/blogs\/show-hidden-files-in-linux-command\/\">Show Hidden Files in Linux Command<\/a><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_a_Symbolic_Link_to_the_Linux_Directory\"><\/span><strong>Create a Symbolic Link to the Linux Directory<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><u>A directory can be referred to through a symbolic link. Under Linux, the following steps must be followed:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>stock photos \/stock photos ln -s \/mnt\/external drive<\/code><\/li>\n<\/ul>\n\n\n\n<p>In the home (\/) directory, this example creates a symbolic link with the name stock photos. The external drive&#8217;s stock photos directory is the location of the link.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Overwrite_Symbolic_Links_Using_Force\"><\/span><strong>Overwrite Symbolic Links Using Force<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><u>One possible error message is shown in the image below:<\/u><\/p>\n\n\n\n<p><iframe title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/zfSa-PEU3h4\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n\n\n\n<p>The error message informs the user that a file with the name link file.txt already exists in the destination. To make the system overwrite the destination link, use the -f option:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>test file.txt, link file.txt, and ln -sf<\/code><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Link_Removal_or_Removal\"><\/span><strong>Link Removal or Removal<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The link will no longer work if the original file is relocated, removed, or if it becomes inaccessible (for example, if a server goes offline). Use either the rm (removal) or unlink command to delete a symbolic link:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>delete link file.txt<\/code><\/li>\n<\/ul>\n\n\n\n<p>Disconnect link file.txt<\/p>\n\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-aaa58f13 wp-block-button uag-blocks-common-selector\" style=\"--z-index-desktop:479;;--z-index-tablet:undefined;;--z-index-mobile:undefined;\"><div class=\"uagb-cta__wrap\"><h2 class=\"uagb-cta__title\"><span class=\"ez-toc-section\" id=\"Supercharge_Your_WordPress_Hosting%E2%80%94Sign_Up_Enjoy_Discounts\"><\/span><a href=\"https:\/\/arzhost.com\/wordpress-hosting\/\" data-type=\"link\" data-id=\"https:\/\/arzhost.com\/wordpress-hosting\/\">Supercharge Your WordPress Hosting\u2014Sign Up &amp; Enjoy Discounts!<\/a><span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"uagb-cta__desc\">Enhance Your WordPress Site with ARZ Host\u2014Starting at just <strong>$0.99\/month<\/strong><\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/arzhost.com\/wordpress-hosting\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_self\" rel=\"noopener noreferrer\">Read More<\/a><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Hard_Links_vs_Soft_Links\"><\/span><strong>Hard Links vs. Soft Links<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>A link can be made in one of two ways using the ln command:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Soft links<\/li>\n\n\n\n<li>Hard links<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Soft_Symbolic_Links\"><\/span><strong>1: Soft (Symbolic) Links<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A soft link, also known as a symbolic link or symbolic, directs users to the path or location of the original file. On the internet, it operates much like a hyperlink.<\/p>\n\n\n\n<p><u>How to Create Symbolic Links in <a href=\"https:\/\/arzhost.com\/blogs\/how-to-list-running-processes-in-linux\/\"><strong>Linux<\/strong><\/a>? Here are some crucial features of a soft link:<\/u><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The original data is still present even if the symbolic link file is removed.<\/li>\n\n\n\n<li>The symbolic link will not operate if the original file is moved or removed.<\/li>\n\n\n\n<li>A file on a different file system may be referenced using a soft link.<\/li>\n\n\n\n<li>To easily access a commonly used file without typing the complete location, soft links are widely utilized. <\/li>\n<\/ol>\n\n\n\n<p>Learn the <a href=\"https:\/\/arzhost.com\/blogs\/learn-nmap-linux-networking\/\"><strong>Basics of Nmap for Linux Networking<\/strong><\/a> for a better understanding how links work.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Hard_Links\"><\/span><strong>2: Hard Links<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><u>Several things occur when a file is saved to a hard drive:<\/u><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The disc receives a physical write of the data.<\/li>\n\n\n\n<li>To point to the location of the data, an internal reference file called inode is made.<\/li>\n\n\n\n<li>The inode data is given a filename to be used as a reference.<\/li>\n<\/ol>\n\n\n\n<p>A hard link operates by establishing a new filename that points to the original file&#8217;s inode information. In actuality, it&#8217;s comparable to making a copy of the file.<\/p>\n\n\n\n<p>Wish to build a Linux Kernel? See our detailed Guide: <a href=\"https:\/\/arzhost.com\/blogs\/build-your-own-linux-kernel-from-scratch\/\"><strong>Build Your Own Linux Kernel from Scratch<\/strong><\/a> and start Creating your very own Linux kernel Today!<\/p>\n\n\n\n<p><u>Here are some crucial characteristics of hard links:<\/u><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Other hard links allow access to the file data even if the original file is removed.<\/li>\n\n\n\n<li>Hard links still function even if the original file is moved.<\/li>\n\n\n\n<li>Only files located in the same file system can be referenced by a hard link.<\/li>\n\n\n\n<li>When there are no harder links, both the inode and the file data are permanently erased.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now that you&#8217;ve learned about hard and symbolic (soft) links, you should be able to use them effectively. How to Create Symbolic Links in Linux? using the ln command, then use the ls tool to check them.<\/p>\n\n\n\n<p>For Powerful and Reliable Hosting Solutions, give us a call at <a href=\"https:\/\/arzhost.com\/\"><strong>ARZ Host<\/strong><\/a>.<\/p>\n\n\n\n<p><strong>Latest Posts:<\/strong><\/p>\n\n\n<ul class=\"wp-block-latest-posts__list wp-block-latest-posts\"><li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/how-to-fix-403-forbidden-error-wordpress\/\">How To Fix 403 Forbidden Error WordPress<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/how-to-get-the-most-out-of-claude-ai\/\">How To Get The Most Out Of Claude Ai<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/bad-gateway-error-502-the-ultimate-guide-to-quick-fixes\/\">Bad Gateway Error (502): The Ultimate Guide to Quick Fixes<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/a-deep-dive-into-todays-best-linux-distros\/\">A Deep Dive Into Today\u2019s Best Linux Distros<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/domain-investor-terms-powerful-strategy\/\">Domain Investor Terms: Expert Insight on Powerful Strategy<\/a><\/li>\n<\/ul>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: Symbolic Links in Linux and What They are Important A file or folder is referenced via a link. In Linux, we see How to Create Symbolic Links in Linux? symbolic links are used to organize and manage files. For Related Articles and Guides, Subscribe to our Blog and get the latest news on Technology! [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6073,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[212,198,256,172],"table_tags":[],"class_list":["post-4967","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-guide","tag-linux","tag-symbolic-links","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/4967","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/comments?post=4967"}],"version-history":[{"count":4,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/4967\/revisions"}],"predecessor-version":[{"id":6074,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/4967\/revisions\/6074"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/media\/6073"}],"wp:attachment":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/media?parent=4967"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/categories?post=4967"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/tags?post=4967"},{"taxonomy":"table_tags","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/table_tags?post=4967"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}