Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Over the course of the next several movies I want to take a look at how to work with links in Unix. Conceptually, links are similar to file aliases that you create in the Mac OS X Finder. You may already be familiar with those, but they're not the same thing and it's important for us to understand the differences between them. We'll start by taking a look at the way that the Mac OS X Finder aliases work. And to begin with, let's just create a simple file. So notice that I am already inside my unix_files directory and I'll create a new file. I'll call it linkedfile.txt and in it, I'll just put some sample text, Link test.
Ctrl+X to exit, yes to save the changes, and return to accept the name that it wanted to give me. Now if we do ls -la, we can see that file we just created right here. Notice that the size of the file is 10. That's because there are just ten characters in it. That's what it's storing and keeping track of, and it's just a normal regular file here. That's what this dash at the beginning indicates. Pay attention to those as we look at all these example, because they will change between the different options that we are going to look at. Now let's create an aliases to it in the Finder. This is not in Unix, this is in the Mac OS X Finder.
We find the file inside unix_file, here is linkedfile.txt, and then we can create an alias in a couple of ways. From the File menu, we can select Make Alias or we can use the Command+L shortcut that you see there, or we can actually Option+Command+Drag the file and it'll create an alias that way. I am just going to choose the File menu item and I am going to rename this file as well to be alias_to_linkedfile, okay. Notice that it has an arrow on the icon to indicate that's it's an alias. That's an indication in the Finder that if we were to double-click on this file it would act as if it were opening the original file.
It would find that original and open that file up. Now, there's a couple of important points about the way that the Finder aliases work. First if the file or the alias moves it still points to the file. The alias still points to the file, no matter where we relocate the two of them in the file system. The Finder will help make sure that the two can always find each other. And if the file is deleted, then the alias will break, because the alias will still be sitting there but when we double-click on it, it will try go and find the original file. But the original file is now gone so it can't open it up.
So the alias essentially still sits there as a dead end. We can also make aliases of folders as well. So if we click on test1 and we pick Make Alias, it will make and alias for that as well, and I'll just rename that alias_ to_test1, and I will pop back up to the top. Now, lets take a look at these in Unix. So ls -la, I'll just clear my screen first. So take a look at each of these. Notice that both of them have much larger file sizes. This one right here is significantly larger. They both also are just regular files. Notice the dash at the beginning.
So that just lets us know that they're just regular files that point to these other ones. So what's in these files that makes them be so large? Well, that's the information that the Finder is using to be able to keep track of these things. So that as the two move around in the file system, it has all the information it needs to be able to locate that file. That's what's inside there. So on the Finder side, if we were to double-click on alias_to_test1, it opens test1 for us. If we click alias_to_linkedfile, you see that it opens up for us.
But on the Unix side, that's not the case. Lets try opening up the file in our text editor. nano alias_to_linkedfile. Well, look what we get back. All sorts of information that Finder is using, but it did not actually use the file. It did not alias the original file. And if we do cd alias_to_test1 and try and change directory, it says oops, that's not a directory. We can't change directory into that. That's a file. So these files are very useful to the Finder and for the Finder to do its thing, but they are useless to us outside of the Finder.
They are really for the Finder and they do their job very well, for the Finder. But in Unix, these kind of aliases are useless. Instead what we are going to need to use in Unix is Unix version of aliases which are called links.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 97196 Viewers
61 Video lessons · 84482 Viewers
71 Video lessons · 68688 Viewers
56 Video lessons · 101172 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.