Linux Format

Network shares

Explore different sharing systems and set up file and folder shares

-

Nick Peers loves doing the samba but not so much when he needs to do the SMB with the CIFS. We’re so Strictly Come Dancing.

Nick Peers goes hunting for the ins and outs of sharing files with other PCs on your network.

Sharing files between computers is one of the most fundamenta­l reasons for setting up a local network. It’s something that’s designed to work seamlessly with your day-to-day file browsing, so everything’s handled using shared folders, which are made accessible to other computers connected to the same local network.

Users can control exactly who has access to each folder and determine what rights they have over the files within that folder. These rights can usually be boiled down to two basic settings: full read/write access and read-only. The latter makes it possible to share files securely without worrying about your files being overwritte­n or deleted – other users can copy files from the shared folder as well as view them, but they can’t perform any kind of editing on the folder or the contents stored in it.

One crucial difference between file sharing in Linux and other operating systems is that permission­s for files inside the shared folder are independen­t to the shared folder itself, so simply granting someone full access to that folder doesn’t automatica­lly grant users full access to the files within – they can delete those files (so some care is required), but they can’t necessaril­y open or edit them unless the files themselves explicitly allow it. This can be awkward, but as you’ll discover, it’s possible to change this behaviour.

If you’re running Ubuntu (we’re using 14.04.3 LTS in this tutorial), then the likelihood is that everything you need to access shared folders are already in place, but you’ll need to add additional packages if you want to turn your PC into a server in order to share files with others. In this tutorial, we’ll reveal all the prerequisi­tes you need to enable all aspects of file sharing on your system, as well as show you how to set up a shared folder for others to access. We’ll also look at different sharing systems, explore issues with access control (typically revolving around folder permission­s) and provide you with all the tools you need to become a file-sharing guru.

Networking sharing is all about acronyms and strange words like ‘Samba’. First up are SMB, which stands for Server Message Block, and CIFS, which stands for Common Internet File System. SMB and CIFS are largely interchang­eable (CIFS is a version of SMB) and basically provide shared access to files, printers and other resources over a local network. SMB/ CIFS is primarily associated with PCs running Windows, which makes it the best solution for those running a mixed network of Windows and Linux PCs, as well as Apple Macs.

Next is NFS, or Network File System. This is an open standard specifical­ly designed to allow client PCs to access files over a network in a similar way to those stored locally on the computer. NFS and SMB/CIFS are competing standards, but you can run both side-by-side in Linux.

In this tutorial we’ll focus on Samba for compatibil­ity purposes, but NFS does have advantages of its own, particular­ly on a closed network where you know every single device that’s connected to it. It’s actually more efficient than Samba, making it quicker and less demanding on the server, but trickier to set up beyond basic home folder sharing ( see NFSSharing­box,p70formore­informatio­nonusingit).

Setting up network shares in Linux

First things first: how do you share a folder on your PC with other computers attached to your local network using Samba? The irony is, although Samba is the simplest option – and the only practical one on a network of mixed computers – it can still be quite complicate­d to administer. Thankfully, though, if your file-sharing needs are basic, it’s actually quite simple. First, you’ll need to install two additional packages before you can start sharing folders: sudo apt-get install samba sudo apt-get install libpam-smbpass

Reboot, then browse to the folder that you wish to share – for simplicity’s sake (and to ensure that you have all the right permission­s), make sure this is one in your personal Home folder. Right-click the folder and choose ‘Properties’, then switch to the Local Network Share tab. Tick ‘Share this folder’, then – if required – choose a different share name for the folder to make it easier for users to identify on the network (you can also add a comment to the folder to make it easier to identify).

Deciding who receives what access to your shared folder can be as simple or as complicate­d as you want to make it. If you’re happy to open up your folder to anyone that is on your network, then ticking the ‘Guest access…’ box under the Local Network Share tab of the shared folder’s properties is

sufficient to do this. However, if you leave this unticked then the only way to access the folder over the network as things currently stand is by logging in with your local account’s username and password.

Next, decide whether users can copy files to the folder as well as delete those within it (tick the ‘Allow others to create and delete files in this folder’ box), click ‘Create Share’ or ‘Modify Share’ and you’re done: the folder should now be visible and accessible over the network to all other connected computers, including Apple Macs and Windows PCs.

Access shared folders

Now you’ve shared a folder, how do you access it – or indeed any other shared folder on your network, including those on Macs and Windows PCs? The answer is incredibly easy – if everything’s set up correctly. Your computer’s name will now be visible to other users when browsing the network, while typing its name or IP address into the ‘Connect to server’ box should also get you access.

Access through Ubuntu is simple too – in fact, other PCs running Ubuntu don’t need to install any additional packages for basic access to your shares; support is baked into Unity’s default file manager as well as the launcher itself. Open Files, then click ‘Browse Network’ under ‘Network’ in the left-hand pane or choose File > Connect to Server… and click ‘Browse’. The file manager supports both NFS and Samba shares, and you’ll be prompted to log in using whatever credential­s are required (with Windows shares, ignore the Domain field if you’re connecting via a workgroup, which is likely in most home user environmen­ts).

By default, you’ll need to re-connect to the share each time you log on. This can be a long-winded process, even if you’ve opted to save your login credential­s forever. One work around is to bookmark the shared folder (right-click its entry in the left-hand pane of the file manager under Network and choose ‘Add Bookmark'), which gives you one-click access from the file manager, but you’ll still have to manually click the link to mount the share each time you restart your PC.

If you’d like more control over the whole process – such as being able to mount a shared folder automatica­lly at startup – then you have one of two options. The simplest one involves a package called Gigolo, which is a graphical front-end for the userspace virtual filesystem GIO/GVfs ( seethequic­ktipbox, left,formoreinf­ormation).

If you’d like maximum control – including being able to mount your shared folder to a directory under mnt – then you’ll need to install cifs-utils, which you can get through SoftwareCe­nter (or via sudo apt-get install cifs-utils in the Terminal). Once installed, create a mount point in the media folder, replacing <sharename> with your choice of shared folder: sudo mkdir /media/<sharename> . Next, if you’re planning to automount Windows shares – particular­ly those on computers without static IP addresses – then do: sudo apt-get install libnss-winbind winbind sudo nano /etc/nsswitch.conf Change the line ‘hosts: files mdns4_minimal [NOTFOUND=return] dns’ to the following: hosts: files mdns4_minimal [NOTFOUND=return] wins dns Restart the networking service ( sudo service networkman­ager restart ) or reboot your PC, then test the service by typing ping <hostname> where <hostname> is the computer name assigned to your Windows PC. Press Ctrl+z to end the ping when you’ve seen if it’s working or not.

Next, create a hidden file to store your Windows username and password securely: sudo nano ~/.smbcredent­ials . Type

 ??  ?? Our expert has been playing around with computers for over 30 years, and dabbling with Linux for the best part of a decade.Nick Peers
Our expert has been playing around with computers for over 30 years, and dabbling with Linux for the best part of a decade.Nick Peers
 ??  ?? Basic folder sharing can be set up in Ubuntu very easily and directly from the file manager using Samba and the Local Network Share tab.
Basic folder sharing can be set up in Ubuntu very easily and directly from the file manager using Samba and the Local Network Share tab.

Newspapers in English

Newspapers from Australia