CompTIA Linux+ XK0-005 – Unit 10 – File Sharing and Printing part 1
All right, so in this section, we’re going to talk about file sharing and printing, which means that either we’re going to offer some services or resources as a printer or a share to others on the network, or we’re going to connect to somebody else’s resources, whether a printer or a shared folder, and be able to access their information. So no matter which direction we go, that remote access, whether to us or from us, is a matter of sharing. And that’s what we’re going to cover, is how do you set that up so that you can do either
All right, so we’re going to start off by talking about the network file resources and then the next section we’ll do with printing. So let’s just focus on what we can do to either share or connect to a shared or do both when it comes to actual files.
So the protocol that we like to use for accessing things remotely in Linux is called the NFS, the network file system. Now, this is something that Windows can also use often if they have some sort of third party software running. Otherwise, Windows uses a SMB, a server message block, or some other types of their technology that is proprietary to them. Now, NFS is a way that we can allow remote access to our file system. Now, that’s kind of an odd way of saying that, because most people say, well, I’m just sharing a folder. Well, technically you’re sharing a part of your file system where in the hierarchy you begin to share is up to you, but it is all a part of your file system hierarchy.
NFS, as I said, is supported by Linux and Unix and Windows with that third party. Now, it is installable as a package and it also utilizes name resolution. In fact, we prefer that when people either connecting to you or you connecting to them, that you make the connection via their host name and not their IP address. A couple of reasons why. Number one is, by connecting by their host name, should their IP address change, the next time you connect, the DNS server will resolve that for you appropriately. If you connect by their IP address and either your IP address changes or theirs change, you’re in a new network, whatever the case may be.
That’s harder to deal with in repairing those connections. Whereas a name resolution can automatically figure out if you’re in the same subnet if they’re in a new subnet because of that DNS service. So anyway, that’s what we’re looking at. Now, if you are sharing a part of your file system, we would call you the NFS server and the person connecting to you would be the NFS client. Again, you can be a client, you can be a server, you can be both. It’s just a matter of perspective of if somebody’s connecting to you or if you’re connecting from your machine to someone else.
All right, so remember, we’re in a virtual environment and we have two different versions of Linux running the Stebian and Fedora. And our goal here is to work with installing the network file system so that we can share folders and communicate between each other. One of the first things they want us to do is record the addresses of each of these devices. So you can kind of see where I’m looking at the Debian system and I’m the 56 address on this network. My host name is Debian, all right? And I need that same information on the other system. So I’m going to quickly switch to the other system. So by moving my mouse to the top, I can click on the next powered machine and I have this information already up for you. That it’s 58. And over here I can still type the hostname command and its hostname is Fedora.
So that’s some of the stuff that we wanted to see and be able to record so we can enter the correct information. Now what we’re going to do is we’re going to add a new entry into our host file because our local DNS is not going to be set up to handle this. And if you remember, I am currently on the Fedora machine and I am see who am I, make sure I’m root and I am. And we’re going to use VI to edit the Etsy hosts file. And now that I’ve got that information, I’m going to come down to the end here of this line, hit the A for a Pen mode, hit Enter, and we’re going to put in the address for the Debian machine, which is 192, 168, 156. And we’re going to hit the space bar to move over to this location. And it was Fedora lowercase, all right, escape to get out of that and colon W to write those changes and colon Q to quit.
And we need to do that as well. Now on the other side, but let’s just test that real quick. Let’s ping the debbie. And in fact, actually I might have just moved that the wrong way. That’s right, I’m on the Fedora box and I just set it up, unfortunately, for Fedora instead of the other. So look at that, I get to already make a change to this location. So let’s just colon D and delete that line, come back up here, we’ll try that again. I’ll go to the end, hit the A for the host Enter. Let’s try this right the right way. I’m on Fedora and so I want to set this up to connect to Debian and of course that’s what happens sometimes when I get to talking and typing at the same time. All right, so I’m glad I was thinking about it and it’s good for you to see how to keep using this VI.
All right, so now I’m going to ping Debian and there you can see that it did look up for the address. And I’m getting a successful ping. So we know that Fedora now after my doing it twice for you, is set up to go out there and connect to Debian by its IP address. And we need to go do the same thing on the Debian system. So let me again switch over to the Debian. And one more time here. We’re going to take a look at the VI and we’ll open up the same Etsy hosts file with VI. And what we’re going to do is actually get rid of this local entry that we have for the Debian machine. So again, that was going to be colon d enter. That’s the line delete, move up to the end of this line. I’m going to hit a for append. Enter for the new line. 192, 168, 158. And that was for Fedora. So escape to stop the edit mode or the append mode and the colon.
Let’s try WQ this time to write and quit. Let’s cat that file just to make sure that it did that. And I see Fedora. So let’s ping fedora and there you can see it’s looked up the right address. So, okay, we are on our way to getting this information set up. And the next thing that we need to do is make sure that one of us anyway is ready to be able to share some folders. So we’ve done the pings, we’ve checked our connectivity. What we’re going to do now is install the NFS kernel server package and all of its dependencies so that we will be ready to actually have remote access or remote connections. So I’m going to go up to system and administration synaptic package manager, close this window out of our way and could be under communications.
But again, I just prefer hitting search. We’ll type in NFS and scroll through the options that we have here under NFS. All of these have something to do with it. But here’s the one I wanted was the kernel server package. Mark that for installation. We’re going to go ahead and apply that, apply all of that package. And when it’s done, we’ll be ready to begin allowing people to connect to us remotely. And we’ll take a look at that in some of our subsequent demonstrations. So there we go. We’ve just recorded some information, set up our host files, verified our connectivity. We know that we can reach them by their actual host name. So when we come back with some other demo, we’ll move a little further in setting up these NFS systems.
Now, if you want to configure yourself as the NFS server there are some configuration files that you’re going to go through. Now, the actual files are going to be under the Etsy directory and the most important one you’re going to deal with is the exports file. Now, this is your way of being able to indicate which file systems are going to be exported, the permissions that they’re going to have and which hosts that are out there may mount those shared shares. Now, if you’re a Windows person this idea of mounting an NFS share is the same thing as talking about making a hard drive connection to a remote share. I think we even called it in windows mounting a drive to an external share. Same idea as I give kind of a method of accessing that share through our file system. The only difference is mounting here is as in any mounting is it appears to us as another directory rather than a drive letter.
Anyway, so the exports is the file systems that you’re going to share, the ones you’re going to export what the permissions are again, permissions are a big deal because you might only want read access and not read write. So you have to choose the permissions. And of course, if you want to specify which hosts can get in there and permanently make connections connections to you you also have a host Allow configuration file that will allow you to say which hosts are permitted to mount the exported file systems explicitly and you have a host Deny which is an explicit which hosts cannot make connections to you. So you have another way of kind of filtering those that you do allow or don’t allow to have connections to your exported file systems.
The exports file, as I said, is your way of being able to say what files you want to export and again, remember the hosts and their permissions that you want. Now, if you were to take a look at some of the examples that you see here, you see a few examples for different types of NFS versions that you have, but roughly they follow the same category. And that is you supply the path to the file that you want to export or the directory you want to export, and then you list the name of the host who can mount that and what their permissions are. RW would be read write r o would be read only whether or not you want them to sync, whether or not you want them to be able to look at the subtrees or the sub directories. And you do that for each of the hosts that you want to have permissions to be able to make those connections. And again, the format just slightly different between the different versions of NFL. It all depends on what you’re running, but you get the idea. Exports file is a nice, easy way to make sure these are always there and ready to go.
Now, when you’re trying to translate this file about what you’re wanting to export, the way in which you list the name of the host is up to you. You could do it as easily as just the host name. Let’s say machine. One, two, three. You might want to specify the actual domain being more exact or what we call a fully qualified domain name. So you might put in machine one, two, three. MyDomain. com you might might want to list it by their specific IP address, 192, 168, 1123, as an example. But if you wanted to include more machines than just that one specific one, then you might put an entire subnet instead of a specific IP address. Now, in order to do that, you have to actually list just the network portion of the IP, followed by what we call a subnet mask, so that we know which you’re masking off as the network and which is wide open to be the host.
So where I earlier said it could be a specific address like 192, 168, 1123, that is a specific who I wanted to connect or allow to have connections to. If I was more vague and said 192, 168 10 well, we assume the zero means anybody. But just in case, the subnet mask to block it off the network portion. And by the way, the first three members of the network portion, the subnet mask to block it off would read 255-255-2550. So I said 255 three times because it blocks off the first three parts of that IP address. The zero at the mask is basically saying everything in that last bite, that last dotted decimal is wide open.
So that could potentially allow 254 hosts to connect well, likewise, if you don’t know the IP addresses, but you know the domain they’re coming from, you could put an entry like Star MyDomain. com, which means any host in that domain could make the connections or at core servers, again, specify a group of people. Or you could go out there and just manually put them in by names. If you want multiple names, you have a lot of options like GSS, GSS, and go in that direction. So you have some options, many options about how you’re going to be able to list the computer entries for the permissions of those NFS shares that you’re going to make.
Now, once you list which systems you’re talking about, the next part of the configuration of that file were the options like permissions, Ro for read only, RW for read write. I think those are pretty selfexplanatory secure or insecure as far as the type of connection. The secure port is the default. So if you don’t list it, it’s going to be secure sync versus Async. Now, the difference here is, let’s say that there are chains changes in cache pending to be made to the file that you’re trying to get. By opting Sync, which is the default. You have to wait until those updates are made out of cache to the file on the hard drive. Then you can basically check it out or grab that file. Async would let you take a file even though there might be pending changes coming into that system. So it’s your choice of how you want the server to behave about changes yet to be made to a file. It’s being shared.
All right, we are going to quickly on the debian system, the one that is going to be running the NFS kernel server. We’re going to set up the exports so that we can basically help somebody connect to us. So we’re going to go to the exports configurations. We’ll move down to the very last line and a for a Pen mode hit enter. And we’re going to basically typically make available the home folder and we’re going to make that available to Fedora for read only. Okay, so this escape this quickly here. Let’s delete that line again. Let’s try it again. I put a zero in there. So try it one more time. The home folder for Fedora and again, read only. There we go. And we’ve got that part done, escape. So we’ll save it right and quit. And then from there we’ll do the cat real quick just to make sure that it looks right. So there it looks like I have the home and I have the readonly.
The next part is for us to start that service for the kernel for the NFS. So that’s another one of those initiatives that we’re going to go through. And it’s the NFS kernel server. And start again. You got to like that tab key. It makes me look like the fastest typer out there. And we’ll start that and it says exporting directories for the NFS, Colonel Damon. And neither subtree nor a subtree check specified for export on home. It’s assuming the default behavior. It’s warning us that there’s no subtree check and that this default has changed since this other version. That’s actually nothing we care about. So we know that we are exporting home. That’s what it’s telling us for Fedora and assumes this default behavior we already know. We set it up as readonly and basically it’s telling us that this network file system is mounted. So we have an exported directory and we have the Damon running and we’re good to go.
Now when we talk about mounting an NFS file system, we’re basically saying we’re going to mount it like we would a hard drive. We’re going to create a point in our file system that represents that remote system. The command is literally the same as it was for any other mounting. You start off with mount T for the type only. The type of course is NFS. The next thing you do is you put in the name of the computer, the file system or the name of the file system of theirs that they’re sharing. And then you put in the name of the mount point that you’re going to use in your file system that represents that computer.
Again, it would be nice if you used a mount point that would somehow indicate that it is a remote connection just by its name. But it still looks to us like a regular directory. All the same rules to mounting curve. You make it a mount point of a directory that already exists and has files. Those files are invisible until it’s gone. And all those things that we talked about when we dealt specifically with mounting hard drives.
All right, so we have a shared folder, for lack of a better term. We have a resource on the Debian and I’m just checking to make sure I have connectivity to Debian that we’re resolving the name and I’m going to make a directory in my mount folder called let’s just call it Debian. And I’m going to mount the shared folder that’s over there into that location. Now let’s do a quick LS mount debian so you can see like magic. It’s empty at the moment. So now I’m going to go in here and do the mount command and we’re going to put in the dash T for the type, and it’s an NFS mount and it’s at the Debian home. And I’m going to put put it in the Mount Debian folder and we hit enter and well, okay, that seemed to work out just fine. Doesn’t seem to anyway cause me any grief when I type that in here. Now let’s do LS mount Debian and there we see this new little folder in there called Trainer.
And let’s go look in Trainer and there you can see what looks like a general home folder for that person. So that was pretty straightforward. Let’s see if I do this touch. Actually, let’s go to that folder. Let’s go to CD mount debian Trainer and let’s do a Touch my file. And there it’s confirming that we set it up as a read only back on Debian so I can’t get in there no matter how hard I try. And now what I’m going to do is I’m going to up arrow until I get to the mount command. We use control A and type in the U mount. So I’m going to unmount oh, device is busy because hey, guess who’s still in there. Let’s back out of it a little bit. And now let’s unmount it. Still busy. So let me see if I can get out of there all the way.
Let’s CD to my home directory and we’ll actually just try without being tricky. I’ll just use the actual command unmount debianhome. There we go. Of course I was trying to be cheating just a bit by actually using the previous command line, but I just went ahead and made sure that I did it all right. And just to make sure we’ll look at the LS mount debian is there because I made that directory. Let’s do LS mount debian, make sure we don’t see anything in there, nothing in there. So it is definitely gone. And while we’re at it, I can remove the directory that I made mount debian and pretty much we’ve cleaned everything up so I’ll clear my screen. So there we were able to use NFS Ah to connect to a resource that was on another system and mount that folder to our local file system.
Now, as you’re working with this file system, the NFS, it’s important to know how it’s behaving, who’s connected, and all the rest of those things. So if you wanted to, there are some commands that can help you in managing NFS. For example, the show mount command would let you see all active connections that you have to these NFS Sharepoints. The export FS command would let you list all of the exported file systems that you’re allowing people to have access to. In fact, sometimes that’s kind of important because you might have some shares that maybe over time, you’ve forgotten about. And so it’s important to look at those. So you can say, oh, yeah, that’s still current, or, wait a minute, that stuff I don’t want to share anymore. So looking at those helps you manage the active connections and what you’re sharing.
Popular posts
Recent Posts