![]() ![]() I hope this brief tutorial on the ln command and symbolic links in Linux has been helpful. ![]() Linux ln command and symbolic links - summary If someone else would like to add some comments about it below, you're welcome to do so. But I don't want to talk about this ln command feature because I don't use it much any more. There are other ways to tell that these files are indeed the same, including the use of the md5sum command. The only giveaway that these files are actually the same file is a) their file size is the same, and b) the number "2" just after the permissions column indicates that there are two links to the file. rw-r-r- 2 Al staff 269894 May 21 17:00 foo.pdfĪs you can see, there is no arrow pointing from one file to the other, and no letter 'l' in the first column. ![]() If you issue an "ls -l" command at this point, you'll see that there is a significant difference between a Linux symbolic link and a hard link: Here I have create a "hard link" between the file named Getting-Started.pdf and a new file named foo.pdf. To do this, I again use the Linux ln command, but this time I leave off the "-s" argument, like this: In this example, I have a file named Getting-Started.pdf, and I know that I want to create a hard link to this file. ![]() Therefore, I won't say much about hard links with the ln command, but I will share one example. I don't use these too often, in part because they can get confusing. Using the Linux ln command you can also create something named a "hard link". That's one more important thing to note: You can use symbolic links in Linux to link to either a file or a folder, no problem. One thing to note about the Linux ln command I use in that example is that I didn't specify a name for the symbolic link, I just used this command:īy just using the decimal/period key at the end of that command, I told the Linux ln command to just use the same for the link as the name of the file or folder that I linked to. Lrwxr-xr-x 1 Al staff 23 Jun 4 19:33 Music -> /Users/Al/Desktop/Music In the example shown here, I created a symbolic link to a directory named "Music" that I keep on my Mac Desktop:Īfter creating this symbolic link to my Music folder, when I use the Linux ls command to list the files in my Dropbox folder, I now see a symbolic link to my Music folder. You can move all your data into that Dropbox folder if you like, or, you can do what I did, and create a symbolic link to your data. The way Dropbox works is that your data needs to appear to be in a special Dropbox folder in your home directory. I just ran across the problem where I needed to create a symbolic link to another file so I could get my files backed up with the Dropbox online backup service. (A "-" in the first column indicates a normal file, and a "d" indicates a directory.) Creating a symbolic link to a file in another directory The 'l' in that first column also shows that this file is really a symbolic link. Another way to tell is by the lowercase letter 'L' in the first column of that listing: That's one way you can tell this "file" is really a symbolic link. rw-r-r- 1 Al staff 1,000 Jun 4 19:39 OriginalFileĪs you can see in that listing, the NewSymbolicLinkFile is shown with an arrow pointing at the OriginalFile. Lrwxr-xr-x 1 Al staff 12 Jun 4 19:39 NewSymbolicLinkFile -> OriginalFile Linux FAQ: How do I create a symbolic link in Linux?Īnswer: To create a symbolic link in Linux, just use the Linux ln command, like this:Īs you can see from my filenames, when using the Linux ln command, you specify the name of the file you're linking to first, and then supply the name of the link second.Īfter issuing the command shown above, when I now issue an "ls -l" command, I now see something like this, showing the symbolic link between the original file and the new "file": ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |