{"id":1012,"date":"2018-10-21T00:12:40","date_gmt":"2018-10-21T00:12:40","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=1012"},"modified":"2018-10-23T01:03:05","modified_gmt":"2018-10-23T01:03:05","slug":"how-to-create-a-symbolic-link-on-ubuntu","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/21\/how-to-create-a-symbolic-link-on-ubuntu\/","title":{"rendered":"How to Create a Symbolic Link on Ubuntu"},"content":{"rendered":"<p>In Linux, there are lots of powerful features that can make the life a lot easier. Linking is one of them that can allow you to perform your tasks a lot faster and more efficiently. You did hear the name \u201csymbolic link\u201d, or more common \u201csymlink\u201d, right? It\u2019s a feature that allows linking to a physical directory or file.<\/p>\n<p>For servers, symlinking is very useful. Are you a Linux user? Then symlink can also help you a lot. All you have to do is be creative with it to lessen your workload.<\/p>\n<p>There are a lot of complex directories in the file system of Linux, right? Remembering all of them can be a real hassle. Moreover, when you want to work with a file\/directory that\u2019s deep within directories and sub-directories, the file path length becomes longer.<\/p>\n<p>It\u2019s especially a pain when working with CLI where you have to specify the file paths. Here comes the symlink to help.<\/p>\n<p>For example, you want to access \u201c\/home\/&lt;username&gt;\/Downloads\/a\/b\/c\/d\/e.txt\u201d file. This is an easy demo, but surely typing the entire file length isn\u2019t something you want to do often, right? With the power of symlink, you can dramatically reduce the file path to \u201c\/home\/e.txt\u201d.<\/p>\n<p>Here, the symlink feature allows you create a virtual file at \u201c\/home\/e.txt\u201d that indicates to the \u201c\/home\/&lt;username&gt;\/Downloads\/a\/b\/c\/d\/e.txt\u201d. Whenever you ask for \u201c\/home\/e.txt\u201d file to manipulate, the system will work on the original file.<\/p>\n<p>The same method goes for directories as well.<\/p>\n<p>Today, let\u2019s check out all how to create a symlink and have fun with it.<\/p>\n<h2>Creating Symlink<\/h2>\n<p>On all the Linux systems, there\u2019s a tool \u201cln\u201d. Don\u2019t confuse with natural logarithm! \u201cln\u201d follows the same structure of \u201ccp\u201d and \u201cmv\u201d. <a href=\"https:\/\/linuxhint.com\/copy_files_copy_directory_linux\/\">Learn more about copying file(s) and directories on Linux<\/a>.<\/p>\n<p>ln -s &lt;source_file_directory&gt; &lt;link_file_directory&gt;<\/p>\n<p>For example, let\u2019s create a symlink of \u201c\/home\/viktor\/Downloads\u201d to \u201c\/Downloads\u201d.<\/p>\n<p>sudo ln -s \/home\/viktor\/Downloads \/Downloads<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1061\" height=\"153\" \/><\/p>\n<p>It\u2019s time to verify the result. Note that you can easily verify the result with a command that works using that directory or file. For example,<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1059\" height=\"92\" \/><\/p>\n<p>I\u2019m now inside \u201c\/Downloads\u201d directory. It\u2019s actually not a new directory. Instead, it\u2019s a link to the original \u201c\/home\/viktor\/Downloads\u201d folder.<\/p>\n<p>Verify that both are the same \u2013<\/p>\n<p>cd \/home\/viktor\/Downloads<\/p>\n<p>ls<\/p>\n<p>cd \/Downloads<\/p>\n<p>ls<\/p>\n<p>See? Both of them are the same!<\/p>\n<p>Let\u2019s do the same with a file. I have already set a demo file \u201cpimusic.txt\u201d on \u201c\/home\/viktor\/Desktop\u201d. Let\u2019s link it as \u201cPIMUSIC\u201d.<\/p>\n<p>sudo ln -s \/home\/viktor\/Desktop\/pimusic.txt PIMUSIC<\/p>\n<p>Verify the result \u2013<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1060\" height=\"738\" \/><\/p>\n<h3>Creating permanent symlink<\/h3>\n<p>Note that the symlinks you create aren\u2019t permanent. Whenever you reboot your system, you have to recreate the symlink again. To make them permanent, simply remove the \u201c-s\u201d flag. Note that it will create a HARD LINK.<\/p>\n<p>sudo ln \/home\/viktor\/Desktop\/pimusic.txt PIMUSIC<\/p>\n<p>Verify the result after rebooting the system \u2013<\/p>\n<p>Enjoy!<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/create_symbolic_link_ubuntu\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Linux, there are lots of powerful features that can make the life a lot easier. Linking is one of them that can allow you to perform your tasks a lot faster and more efficiently. You did hear the name \u201csymbolic link\u201d, or more common \u201csymlink\u201d, right? It\u2019s a feature that allows linking to a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/21\/how-to-create-a-symbolic-link-on-ubuntu\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Create a Symbolic Link on Ubuntu&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1012","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1012","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=1012"}],"version-history":[{"count":2,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1012\/revisions"}],"predecessor-version":[{"id":1379,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1012\/revisions\/1379"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=1012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=1012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=1012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}