Create Users, share drives and folders across the network
Having lots of lovely space on your new server is no good if nothing other than the server itself can see it! So, let's share some drives and folders using Samba so they can be seen by other computers and devices on your network.
If you've not been following this guide from the start and/or do not have Samba installed then you can install samba in one of two ways: via the gnome desktop or via the Command Line.
Using the gnome desktop: choose System -> Administration and then Synaptic Package Manager from the menus. Type samba in the Quick Search box and then place a check against samba in the list of results returned and click Mark For Installation. Choose any additional packages too if prompted. Next click the Apply button and then the Apply button once again for confirmation.
If you do not have the Synaptic Package Manager installed (it is not installed by default under Lucid or Karmic) then you can install it by issuing sudo apt-get install synaptic from a Terminal or Putty session.
Using the Command Line: another way of installing samba on your server is by typing the following two commands either directly onto your server or via Putty:
sudo apt-get update
sudo apt-get install samba
Before we get stuck into how we go about creating users and sharing folders we need to have a firm understanding of the concepts behind Linux File Permissions. This is especially true for those of you who are coming from a Windows background: Understanding Linux File Permissions
Now we have an understanding of the concepts behind users and permissions I'll explain how to share a folder across the network using Webmin and you can take it from there.
First let's create a new user. So, in Webmin, click System -> Users and Groups and click on Create a new user. Give the new user a Username, enter a Real name if required and for the Password click Normal password and supply a password. Under Group Membership use a Primary Group -> Existing group called users. Leave all other options asis and click the Create button. This will create a user which belongs to the users group.
This new user we've just created is only known to our server currently so we'll now convert it into a "networked user". This means we'll be able to use this username to connect to designated files and folders on our server from elsewhere on our network.
So, click Servers -> Samba Windows File Sharing and click on Convert Unix users to Samba users and click on Convert users. Once we've done this we should configure the password for this user. The password for accessing the server via Samba can be the same as the one used to access the server via Putty but we still need to complete this step regardless. So, on the Samba Windows File Sharing screen click Edit Samba users and passwords and then click on the user we've just created. Then check the New password option and enter the required password. Then click Save.
Now re-start Samba via the Samba Windows File Sharing screen by clicking on the Restart Samba Servers button. We should now be able to access those files and folders on our server for which we've given permission to this new user.
Now let's create a folder. We'll create one in our home folder just for illustrative purposes. So, from a Putty/Terminal session type the following:
where YourUserName is your Ubuntu username. This will switch us into your home folder.
to create a folder called "testfolder" within your home folder.
Now, let's share this folder. So back to Webmin and go to Servers -> Samba Windows File Sharing click on Create a new file share and give the Share a name. Click on the Directory to share button and navigate to /home/YourUserName/testfolder. Click OK, change the Create with owner to the user we've just created by clicking on the button next to the field and choosing the new user.
Change the Create with group to be "users" and click the Create button. Now click on the Share Name you just created and then click on the Security and Access Control icon. Select Writable? Yes, and under Valid users click the button and select the user you just created. Then click the Save button.
This new user has read and write access to this "networked folder" (). Obviously for read-only access you'd select "Writable? No"
Making symlinks visible across different shares
There are security issues caused by creating symlinks which point to different shares and so this feature is disabled by default. If you wish to have symlinks that point to files/folders outside the share they are created on then add the following 3 lines to the global section, [global], of the samba config file. So type:
sudo vim /etc/samba/smb.conf
to open the config file for editing. Then press the [Insert] key once to switch into Insert Mode and type or paste the following 3 lines into the file:
follow symlinks = yes
wide links = yes
unix extensions = no
Then press the [Esc] key once and type :wq to save and quit out of the file. If you make a mistake editing the file then issue :q! instead of :wq to abort your changes.
Changing the Windows Workgroup for our Ubuntu server
To make life simpler it's probably a good idea to ensure that our server is in the same workgroup as the rest of the devices on our network. This is typically MSHOME. You can do this in Webmin by going into Servers -> Samba Windows File Sharing and clicking on the Windows Networking icon. Change the Workgroup from WORKGROUP to the name of your own workgroup. eg MSHOME, change the WINS mode to Be WINS server and click the Save button.
Lastly under Servers -> Samba Windows File Sharing click the Restart Samba Servers button at the bottom of the screen.
You can test the new share is working properly by going into Windows Explorer on your windows desktop computer and clicking on My Network Places -> Entire Network and selecting the workgroup (eg. MSHOME). Your server should be listed in there and you should be able to access "testfolder" created above.
If your new server doesn't appear, try pressing the F5 button a few times and/or restarting the server. On mine I had to shut everything down (all computers, servers, everything) and restart my router for the changes to take effect.
Still stuck? Now what you were looking for? Then head over to the Discussion Forum!