Hey everyone and welcome back. So in the previous nugget we had just ended by pointing at the
location of our SAMBA configuration file. Now this file is super-duper important, it's
where we're going to control pretty much everything with respect to our SAMBA server. So what we're
going to do in this nugget right here is to explore what we can find within this configuration
file and then make some changes and we shall do a little bit of testing. So with that said,
how about we dive in directly to this file and see what we can see then. So what I'll do here is
I'll clear my screen and I'll go directly to this file. So I'll cd into the xa directory,
like I say I now should have this SAMBA directory. If you're on an older system, remember this may
be an xa-smb as opposed to SAMBA. But for me, if I do an ls, we can see I actually do have this
smb.conf file. So what I will do here is I'll say sudo nano smb.conf. Remember we're in the xa
directory so we want to have super user privileges to be able to modify this. I will just type in
my password right now and as we can see here, this is the main SAMBA configuration file. Now one
thing to note, we have seen so many times before when we happen to see this hashtag or the pound
symbol, whatever you like to say, this happens to mean that we are dealing with a comment, i.e. we can
prepend some type of sentence with the comment and it's going to have no actual effect on the
configuration file itself. This is purely annotation, which is what we see right here. Now as we're
going to see here, when we scroll on down, you are going to notice these particular headings,
things like global. Now these actually denote different actual sections. Okay, so we can see
here this is for global settings. When we have a new section, it is going to be defined by these
square brackets. So global settings, these are the server's main settings, the primary settings,
if you will. Now some things that you're going to see right here is, for example, the work group. So
this is the option here and this happens to be the value. Now the value here is just called
work group and capital letters. This is the default value that we're going to be using. Now if you
happen to be using things like Windows systems, users automatically are dumped into a work group,
simply called work group and capital letters. And when we are talking about a work group,
all we're talking about is a group of computers on a network that happen to share the same type
of resources. Maybe they want to have access to the same printers or to the same folders. We define
this as a work group, i.e. a collection of those computers. Now this work group here, like I say,
is going to be important when we want to actually be communicating with different systems such as
Windows systems. Now we can also see the server string value. This is ultimately how we can
provide a description of the actual server itself. So we can see here this percentage H. What this is
going to act like is going to act like a variable value i.e. it's not going to be presented as
percentage H. It's actually going to be populated with the server's actual host name. So whatever
the host name of that server is, this is going to specify it right here. And then we can actually
see here within brackets a little description that this is a SAMBA server on Ubuntu. Now again,
if you want to be dealing with Windows, you may actually encounter Wins, which is the Windows
Internet naming service. Although realistically, I can't really imagine that you would find much
use for this. But nevertheless, if you do, you can uncomment this to allow for Wins support. So we
can see here, as we know, we can just remove the hashtag and suddenly the configuration is active.
But for now, we don't want to do such a thing. If we scroll on down, we can see information
relating to how we actually want to log connections coming in to our SAMBA server,
as well as the size of each log. We can see here this is 1000 kilobytes. But if we keep scrolling
on down, and there is a lot to scroll through, we will eventually come to our share definitions here.
Now here is one thing we want to note here. You see these semicolons here on the very left hand side.
These actually also denote comments, which is quite unique, because as we know, the hashtag symbol
is how we comment out particular things, i.e. make sure it is not active. But notice we can also
comment out configurations with this semicolon right here. Now the difference really is that we
want to be using the hashtag for actual comments, i.e. descriptions of what a particular configuration
is going to do. When we want to comment out i.e. to make an act of a particular configuration itself,
we want to prepend it with the semicolon instead. So we can see here, all of this here happens to be
inactive. The stuff that is got the hashtag is just general descriptions that we don't want to be
interpreted as commands. And the actual configurations themselves here, which are written in the correct
syntax, they are actually still an active and not taking effect because they have been commented
with the semicolons. The semicolon is for commenting configurations, and the hashtag is for commenting
actual descriptions that we don't want to be active. Now with respect to this section here called
Homes, this is all about really the simplification of being able to share users home directories,
because as we will find out, there actually is a difference between a SAMBA user and the actual
Linux user account on the system. We'll talk about this a little bit later. Understand though that
these Linux users, just like my IPv0 account, actually have home directories on their systems,
and this particular section relates to simply the sharing of users' particular home directories.
Now throughout this configuration file, we're going to see particular settings such as the comment
setting. This is just going to provide you a way to describe the share that you happen to be
sharing out. In this case here, we can see that the comment is going to say home directories, because
really, this section here, Homes, is all about sharing out users' home directories. So the comment
here is pretty descriptive. We also have additional settings such as the browsable setting, which is
in this case set to no. However, if this was configured to be yes, this would make the share
discoverable to clients who are actually just querying the server for available shares, whereas
when it is set to no, the client actually has to note in advance and be explicit about trying to
find this particular share. So really, if you just want people to easily find the share, then you
would want to make the browsable setting set to yes. If you want to be a little bit more secure,
and hide the share, i.e. make sure that the person knows what they're looking for and have them
specify the name of that particular share, we'd want to set the value to, in this case what we have
here, the value no. Now we can see here we have the option read only. In this case here, this is set
to yes. This would mean that the documents within that particular share could actually be read,
i.e. if you happen to have a text file, someone browsing this share could read that text file,
but they could not modify that text file or write to that text file. It is, as we can see here,
read only. So again, if we keep scrolling on down, we can see here, for example, this one is all
commented out, but now below we can actually see the printers section. So this would be if we want
to share out particular printing ability. We can see here the comment denotes this is for all
printers. Is this browsable? No, we have to know about it. And the path here, this specifies
the actual directory location of the share itself. Should this actually be printable?
Well, within the printer share, this does make sense to have this at the value yes,
which is what we can see here. This is going to allow for this share to be printable. We can see
the guest okay option, which means that is this share available to be accessed by a guest account?
In this case here, we say no. And we can also see this option to create a mask. This is ultimately
talking about permissions, i.e. how we can control particular access to this share. Now,
we'll actually get to look at this in a little bit more detail very, very shortly. But for now,
understand that when we're talking about mass creation, we're talking about permissions. But
for now, what I want to do is I want to scroll down here and I want to actually create my own
little share. Okay, so what I'm going to do is I'm going to define this share using my square
bracket. So I'll just call this maybe let's just say public blah. Okay, it doesn't actually matter
the name of the share. This is how this share is going to be presented. So when someone looks for
this share, it's going to see it as public blah. So whatever you name it in here, this is what is
going to be visible. And I will say comments. I'll just say just testing some share stuff. Now,
the path I want to specify what directory that I actually plan to share here. So what I will do
here is I'll just say forward slash and I'll just call this one public blah. Now, one thing to note
here is that this name does not have to match this name. I'm just matching it to keep things simple,
but this can be any directory you so wish. And what I will say is guest okay, which is equal to
the value. Yes, IE we do not have to have a user account to access this particular share. And I
will say read only and I'll make that the value no IE the share that I'm going to be sharing out
people browsing this share can actually modify it. They can actually write within this directory
and modify files within this directory. So check this out. I want to share this particular directory
public blah. But as it stands right now, if I save this file and I go to the root directory CD
roots, and I do an LS, we do not actually have this particular directory. So what I want to do
is to make this directory has to exist, of course, if I want to share it. So I will say
pseudo MK, forward slash and the directory is going to be called public blah. And I will type
in my password to allow this. And then I'm going to say pseudo CH mod 777 public blah. Now, what I've
done here is I've basically given full read, write access and execute access, by the way,
to absolutely everyone within this public blah directory. Now, the reason why I've done this
is because this happens to be a quite common convention with respect to managing permissions
on Samba. The reason why is because we actually have the file system permissions, and we actually
have the Samba permissions. Now, the file system permissions were the permissions that I just
specified there, I said 777 IE, I'm going to have no restrictions via the file system instead.
What I want to do to make things more manageable is I want to have the restrictions actually
controlled by the Samba server itself. Now, the reason why I've made this so permissible,
i.e. to allow everything is that if I happen to have very specific Samba limitations,
whereby particular users were allowed access and other ones were not, that could actually clash
with the native file system permissions. In fact, the native file system permissions would
override the Samba permissions, and I don't want to do that. I want to have control directly via
Samba. So all I do here is I just make this very permissible, i.e. allow everything, and I will
lock down the access as necessary, just using my Samba configurations. So this is something you
will see fairly often. So now, what I want to do here is I want to test that my Samba configurations
were indeed valid. Now, we do actually have a particular command that can do such a thing.
What I can do here is say test perm, and we can see here it's going to load the config files from
this configuration. And if I hit enter, we can actually see all the definitions of our configurations
right here. So we see this. Now, notice that I don't have any errors popping up. This tells me that
the configurations that I happen to have set here are valid. So what I want to do here is I want to
restart my Samba service. So I'll say sudo system CTL, and I will restart SMBD. And I also want to
restart NMBD. So now if I happen to say sudo system CTL, and I say status of SMBD, I can see that
the Samba SMBD is indeed running. Everything seems to be okay. And if I check NMBD, I can see the
Samba NMBD is indeed also running. Now, there are some particular tools that we can use to query
information about the status of our Samba server. So as we can see here, my server name happens to be
called system. This is the name of the server that happens to be running the Samba service. So what I
can actually do is I can say NMB look up, and I can look up the name of that particular server,
which is called system. And as we can see here, we have made that particular query looking for
this particular name system, and it has returned to us the IP address of the server. Now, this happens
to be my own server, my own IP address. But clients who are using this service could do the same
thing as well. They could look up the name of the Samba server using this look up tool and quickly
find the IP address using this particular command. Remember also, we had this default work group,
just simply called a work group. What I could do is say NMB look up, and I could say a work group,
which is in capital letters, if I hit enter. So this is displaying all of the computers within
the default work group within my local network. I have a bunch of laptops connected here as well
as family members who are also connected to the same network. Using this look up, we can actually
see all the private IP addresses here that happen to be in use. Now, as it transpires, I happen to
be using virtual box on my own Windows system. Now, my Windows system is on the same network as
this virtual machine right here. What I want to do is I want to see if that share that I shared on my
Linux machine, my Samba server is actually available to me as a Windows user on my local
Windows machine. Because like I say, we have shared it out using Samba. Now, the first thing
that I'm going to do right here is I'm going to go down and I'm going to search for turn Windows
features on or off and click this. And I want to click SMB one slash CIFS file sharing support.
Now, when I click OK, this is going to enable this feature. And once you do so, you may have to
restart your system to have the changes take effect. Next, I will open up my control panel.
I will then go into network and internet. I will go to network and sharing center. I will go to
change advanced sharing settings. And what I want to do is I want to turn on network discovery.
And I will click turn on automatic setup of network connected devices. If you haven't got that
setting, then you want to turn that on and then save the changes. Once you have your Samba server
configured and the network discovery on, as well as turning on the Windows feature for SMB 1.0,
what should happen is that when you go to your file explorer, once you click network, you should
actually see the Linux server on the network. So I can see here system, which is the name of my
Linux server. If I double click this, notice here, I actually have the share called public
blank. If I highlight over it, you can see the description or the comment saying just testing
some share stuff. If I go into this directory, what I could do is I could create a new folder
and just call this test 123. And within test 123, I create a new text documents and just call this
hello. And if I open it up and just say hello, this is just some test and I will save this.
If I now go back to my virtual machine right here and I do an LS, we can see within the public
blood directory. If I go into this directory and do an LS once again, we can see the name of the
folder we created on the Windows system, which is being shared. If I do an LS, we can cat this
particular file. We can actually see the contents of this file. And if I wanted to modify it, I could
say sudo nano, go into hello.txt and I could just say adding some stuff via the Linux system.
And I'll save you and exit out. If I minimize this, go back to my Windows and I open the file here.
We can actually see here the modifications have taken place here because the file has been shared
across the network, even though the computers in one case are using a Linux operating system.
And the other happens to be using a Windows operating system. Collaboration, as we can see here,
is still absolutely possible. And this really is the power of using Samba. So that is us for
our basic Samba configuration. We want to be looking at authentication and password a little
bit more closely. And that is what we're going to be doing in the very next nugget. So I hope
it's been informative for you and I'd like to thank you for viewing.