{"id":663,"date":"2025-03-18T11:35:47","date_gmt":"2025-03-18T03:35:47","guid":{"rendered":"https:\/\/witlab.ph\/blog\/?p=663"},"modified":"2025-03-18T11:35:48","modified_gmt":"2025-03-18T03:35:48","slug":"soft-link-and-hard-link-in-linux","status":"publish","type":"post","link":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/","title":{"rendered":"Soft Link and Hard Link in Linux"},"content":{"rendered":"\n<p><strong>What is soft link?<\/strong><\/p>\n\n\n\n<p>Soft link is similar to window folder or file shortcut feature. Also known as symbolic links or symlinks. Soft links are similar to shortcuts in windows. When the target original file or folder is deleted or moved, the soft link becomes a \u201cdangling\u201d link that points to a non-existing file.<\/p>\n\n\n\n<p><strong>Soft link use case<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>to create shortcuts to access files or directories in different locations<\/li>\n\n\n\n<li>to share resources across file systems<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>To create soft link to file<\/p>\n\n\n\n<pre class=\"brush: powershell\">\nln -s \/path\/to\/original\/file.txt \/path\/to\/link\/file-link.txt\n<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>To create soft link to folder<\/p>\n\n\n\n<pre class=\"brush: powershell\">\nln -s \/path\/to\/original\/directory \/path\/to\/link\/directory-link\n<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>To check the link<\/p>\n\n\n\n<pre class=\"brush: powershell\">\nls -l \/path\/to\/link\n#output\nlrwxrwxrwx 1 aung aung 13 Dec 30 14:59 link_soft_file.txt -> soft_file.txt\n<\/pre>\n\n\n\n<p><strong>What is Hard link?<\/strong><\/p>\n\n\n\n<p>Hard links can only point to files and cannot link to a file on different partition with a different inode number. Hard links will work when delete the target original file and the data remains accessible by any of its hard links.<\/p>\n\n\n\n<p>Hard link use case<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>to create backup copies of important files.<\/li>\n\n\n\n<li>to avoid duplicating of same data in the same filesystem<\/li>\n\n\n\n<li>to keep file content accessible even if the original file is deleted<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>To create hard link to file<\/p>\n\n\n\n<pre class=\"brush: powershell\">\nln \/path\/to\/original\/file.txt \/path\/to\/link\/file-link.txt\n<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>To check the link<\/p>\n\n\n\n<pre class=\"brush: powershell\">\nls -i \/path\/to\/original\/file.txt \/path\/to\/link\/file-link.txt\n#output\n6744 hard_file.txt  6744 link_hard_file.txt\n<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use <strong>soft links<\/strong> for <strong>flexibility<\/strong> when using files\/directories across filesystems or when needing to link to directories.<\/li>\n\n\n\n<li>Use <strong>hard links<\/strong> for <strong>resilience<\/strong> and efficient storage when working with files within the same filesystem.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is soft link? Soft link is similar to window folder or file shortcut feature. Also known as symbolic links or symlinks. Soft links are similar to shortcuts in windows. When the target original file or folder is deleted or moved, the soft link becomes a \u201cdangling\u201d link that points to a non-existing file. Soft [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":667,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-663","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-system"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Soft Link and Hard Link in Linux - WIT LAB %<\/title>\n<meta name=\"description\" content=\"We excel in utilizing cutting-edge technology, programming languages, and frameworks to deliver high-quality digital solutions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Soft Link and Hard Link in Linux - WIT LAB %\" \/>\n<meta property=\"og:description\" content=\"We excel in utilizing cutting-edge technology, programming languages, and frameworks to deliver high-quality digital solutions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"WIT LAB\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/people\/WIT-LAB\/61567795364273\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-18T03:35:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-18T03:35:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2025\/03\/SOFT-HARD.png\" \/>\n\t<meta property=\"og:image:width\" content=\"700\" \/>\n\t<meta property=\"og:image:height\" content=\"364\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Aung Nyi Thit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Aung Nyi Thit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/\"},\"author\":{\"name\":\"Aung Nyi Thit\",\"@id\":\"https:\/\/witlab.ph\/blog\/#\/schema\/person\/4df708bd91fad188e81ec5addf45b5c3\"},\"headline\":\"Soft Link and Hard Link in Linux\",\"datePublished\":\"2025-03-18T03:35:47+00:00\",\"dateModified\":\"2025-03-18T03:35:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/\"},\"wordCount\":221,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/witlab.ph\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2025\/03\/SOFT-HARD.png\",\"articleSection\":[\"System\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/\",\"url\":\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/\",\"name\":\"Soft Link and Hard Link in Linux - WIT LAB %\",\"isPartOf\":{\"@id\":\"https:\/\/witlab.ph\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2025\/03\/SOFT-HARD.png\",\"datePublished\":\"2025-03-18T03:35:47+00:00\",\"dateModified\":\"2025-03-18T03:35:48+00:00\",\"description\":\"We excel in utilizing cutting-edge technology, programming languages, and frameworks to deliver high-quality digital solutions.\",\"breadcrumb\":{\"@id\":\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#primaryimage\",\"url\":\"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2025\/03\/SOFT-HARD.png\",\"contentUrl\":\"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2025\/03\/SOFT-HARD.png\",\"width\":700,\"height\":364},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/witlab.ph\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Soft Link and Hard Link in Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/witlab.ph\/blog\/#website\",\"url\":\"https:\/\/witlab.ph\/blog\/\",\"name\":\"WIT LAB\",\"description\":\"Web Development\",\"publisher\":{\"@id\":\"https:\/\/witlab.ph\/blog\/#organization\"},\"alternateName\":\"WIT LAB INC\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/witlab.ph\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/witlab.ph\/blog\/#organization\",\"name\":\"WIT LAB INC\",\"alternateName\":\"Spiceworks (Japan)\",\"url\":\"https:\/\/witlab.ph\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/witlab.ph\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2024\/09\/logo_witlab-Copy-Copy.png\",\"contentUrl\":\"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2024\/09\/logo_witlab-Copy-Copy.png\",\"width\":681,\"height\":616,\"caption\":\"WIT LAB INC\"},\"image\":{\"@id\":\"https:\/\/witlab.ph\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/people\/WIT-LAB\/61567795364273\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/witlab.ph\/blog\/#\/schema\/person\/4df708bd91fad188e81ec5addf45b5c3\",\"name\":\"Aung Nyi Thit\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/witlab.ph\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/56095dd9b0cc972b21cc50c6ae98ce92?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/56095dd9b0cc972b21cc50c6ae98ce92?s=96&d=mm&r=g\",\"caption\":\"Aung Nyi Thit\"},\"sameAs\":[\"http:\/\/rapidspice-wp.local\/blog\"],\"url\":\"https:\/\/witlab.ph\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Soft Link and Hard Link in Linux - WIT LAB %","description":"We excel in utilizing cutting-edge technology, programming languages, and frameworks to deliver high-quality digital solutions.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/","og_locale":"en_US","og_type":"article","og_title":"Soft Link and Hard Link in Linux - WIT LAB %","og_description":"We excel in utilizing cutting-edge technology, programming languages, and frameworks to deliver high-quality digital solutions.","og_url":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/","og_site_name":"WIT LAB","article_publisher":"https:\/\/www.facebook.com\/people\/WIT-LAB\/61567795364273\/","article_published_time":"2025-03-18T03:35:47+00:00","article_modified_time":"2025-03-18T03:35:48+00:00","og_image":[{"width":700,"height":364,"url":"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2025\/03\/SOFT-HARD.png","type":"image\/png"}],"author":"Aung Nyi Thit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Aung Nyi Thit","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#article","isPartOf":{"@id":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/"},"author":{"name":"Aung Nyi Thit","@id":"https:\/\/witlab.ph\/blog\/#\/schema\/person\/4df708bd91fad188e81ec5addf45b5c3"},"headline":"Soft Link and Hard Link in Linux","datePublished":"2025-03-18T03:35:47+00:00","dateModified":"2025-03-18T03:35:48+00:00","mainEntityOfPage":{"@id":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/"},"wordCount":221,"commentCount":0,"publisher":{"@id":"https:\/\/witlab.ph\/blog\/#organization"},"image":{"@id":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2025\/03\/SOFT-HARD.png","articleSection":["System"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/","url":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/","name":"Soft Link and Hard Link in Linux - WIT LAB %","isPartOf":{"@id":"https:\/\/witlab.ph\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#primaryimage"},"image":{"@id":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2025\/03\/SOFT-HARD.png","datePublished":"2025-03-18T03:35:47+00:00","dateModified":"2025-03-18T03:35:48+00:00","description":"We excel in utilizing cutting-edge technology, programming languages, and frameworks to deliver high-quality digital solutions.","breadcrumb":{"@id":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#primaryimage","url":"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2025\/03\/SOFT-HARD.png","contentUrl":"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2025\/03\/SOFT-HARD.png","width":700,"height":364},{"@type":"BreadcrumbList","@id":"https:\/\/witlab.ph\/blog\/soft-link-and-hard-link-in-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/witlab.ph\/blog\/"},{"@type":"ListItem","position":2,"name":"Soft Link and Hard Link in Linux"}]},{"@type":"WebSite","@id":"https:\/\/witlab.ph\/blog\/#website","url":"https:\/\/witlab.ph\/blog\/","name":"WIT LAB","description":"Web Development","publisher":{"@id":"https:\/\/witlab.ph\/blog\/#organization"},"alternateName":"WIT LAB INC","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/witlab.ph\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/witlab.ph\/blog\/#organization","name":"WIT LAB INC","alternateName":"Spiceworks (Japan)","url":"https:\/\/witlab.ph\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/witlab.ph\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2024\/09\/logo_witlab-Copy-Copy.png","contentUrl":"https:\/\/witlab.ph\/blog\/wp-content\/uploads\/2024\/09\/logo_witlab-Copy-Copy.png","width":681,"height":616,"caption":"WIT LAB INC"},"image":{"@id":"https:\/\/witlab.ph\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/people\/WIT-LAB\/61567795364273\/"]},{"@type":"Person","@id":"https:\/\/witlab.ph\/blog\/#\/schema\/person\/4df708bd91fad188e81ec5addf45b5c3","name":"Aung Nyi Thit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/witlab.ph\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/56095dd9b0cc972b21cc50c6ae98ce92?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/56095dd9b0cc972b21cc50c6ae98ce92?s=96&d=mm&r=g","caption":"Aung Nyi Thit"},"sameAs":["http:\/\/rapidspice-wp.local\/blog"],"url":"https:\/\/witlab.ph\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/witlab.ph\/blog\/wp-json\/wp\/v2\/posts\/663"}],"collection":[{"href":"https:\/\/witlab.ph\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/witlab.ph\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/witlab.ph\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/witlab.ph\/blog\/wp-json\/wp\/v2\/comments?post=663"}],"version-history":[{"count":3,"href":"https:\/\/witlab.ph\/blog\/wp-json\/wp\/v2\/posts\/663\/revisions"}],"predecessor-version":[{"id":666,"href":"https:\/\/witlab.ph\/blog\/wp-json\/wp\/v2\/posts\/663\/revisions\/666"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/witlab.ph\/blog\/wp-json\/wp\/v2\/media\/667"}],"wp:attachment":[{"href":"https:\/\/witlab.ph\/blog\/wp-json\/wp\/v2\/media?parent=663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/witlab.ph\/blog\/wp-json\/wp\/v2\/categories?post=663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/witlab.ph\/blog\/wp-json\/wp\/v2\/tags?post=663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}