Creating a share
In the following exercise, we'll make a folder and share it,
so that anyone on the network can access it.
We need to make a folder to share. Linux calls folders 'directories'.
In the terminal, type:
sudo mkdir -p /home/share/ music
This creates the directories 'share' and 'music' in the
/home directory. We will make it open to all. sudo chown nobody.nogroup /
home/share/music
Folder Sharing
This sets the owner of the music directory to nobody and the
group to nogroup. These are the defaults for the guest user, effectively
allowing read, write and execute permissions to everyone.
Back in SWAT, click on the 'shares' button, then enter a
share name in the 'create share' field (I'm using the name 'music'), then click
the 'create share' button.
In the screen that appears, enter /home/ share/music in the
'path' field and change the following:
'Read only' to 'no'
'Guest ok' to 'yes'
'Available' to 'yes'
Click 'commit changes'. Then restart the Samba daemon (a
daemon is the Unix equivalent of a Windows service) with this command:
sudo restart smbd
A few minutes later, you should be able to browse to the
shared folder.
If you don't mind your network shares being accessible to
everyone without needing usernames and passwords, that's it, and as SMB is not
routable, a home network behind a router is probably fairly safe.
If you want usernames and passwords for multiple users,
you'll need to create a Linux user for each one, and then change the Samba
configuration to create matching Samba users. A user on a Windows PC will need
to have the same username and password on the Samba server in order to connect
to a Samba share.
Ports
Computers all have an individual IP address, and there are
standard ports that can be accessed via the network.
For example, SMB operates on 139, web servers default to
port 80, SSH is port 23. To access a port on a remote PC using a web browser,
you need to enter the PC name or IP address, followed by a colon and then the
port number.
You may need to open firewall ports for some services, for
example firewalls can block SMB connections if port 139 is not open on any PCs
that you want to share printers or files with.
There are several distorts that will simplify it for you,
giving you a point and click interface, and there are other tools that can make
managing your server simpler, which we discuss later in the series.
New commands this week
This week, we used the tasksel command to install a 'task'
or preconfigured bundle of programs. Note: tasksel should only be used to
install software, not to remove it, as it will remove all dependencies in a
bundle and might leave your system unusable!
We also used three new commands for altering file
properties:
·
chmod (change mode): changes the permissions on a file. It can
be used in a number of ways. The example shown this week adds write
permission to group users. We shall go into more detail about permissions
next week.
·
chown: changes the owner(and optionally the group) attached to
a file. Usage is 'chown username.groupname filename'.
·
chgrp: changes the group attached to the file. Although users
can be members of many groups, only one user and one group can be attached to
a file.
·
mkdir makes a directory, the -p switch makes it create the path
as well if it doesn't already exist.
|