At the same time an office’s back end might be all Linux, the machines used by employees on a daily basis are not. If you don’t have a file server, it can be really hard to make Linux and Windows machines share files well.

As a solution, installing Samba on a server will allow storing files that should be shared on the server, in a shared folder. Such files can be added or updated through a connection to the server using SSH, FTP, or directly through Samba.

In this tutorial, we’ll cover how to setup a cloud file server with Samba.

Establish SSH connection with the server

Consider that you’re going to control the server through an SSH connection. For this, enter your server’s IP and root username.

If you’re on a remote terminal, use the following command:

$

ssh {{form.server_root_username}}@{{form.server._IP}}

Install Samba

Before you start with the installation, run the following commands to refresh the package list and install any existing updates:

$$

sudo apt-get udpdate sudo apt-get upgrade

After that, install Samba with the command:

$

sudo apt-get install samba samba-common-bin

Create a shared folder

In order to control what you share, create a new shared folder to put everything you want to share with the network:

$

sudo mkdir -m 1777 /share

This command will create a folder called ‘share’ in root.

If you already created a shared folder, update its permissions with the command:

$

sudo chmod -R 1777 /share

Edit Samba configuration file

Access the Samba configuration file with your favorite text editor. In this tutorial we will use nano.

$

sudo nano /etc/samba/smb.conf

Then, paste the following block on the file that will open:

[share] Comment = shared folder Path = /share Browseable = yes Writeable = Yes only guest = no create mask = 0777 directory mask = 0777 Public = yes Guest ok = yes Press CTRL+O, then enter, save and quit.

Set a password

To generate a strong password, get the output of the openssl rand function command. We used 18 as an example, but you can replace it with the number of characters to output:

$

openssl rand -base64 18

Copy the password and then:

$$$$$

sudo smbpasswd -a {{form.Server_root_username}}

Restart the server

You should restart your server in order to apply the changes you made to the configuration file:

$

sudo /etc/init.d/samba restart

Configure user access

You can find everything you need to control directory access and user permissions for your office in the Samba config file. Go to /etc/samba/smb.conf and edit it:

$

sudo nano /etc/samba/smb.conf

In this example, we’ll give access to the user Ana to her own folder. For this, you would add the following block to the configuration file:

[ana] path = /home/ana comment = Ana's home directory writable = yes valid users = ana Then give a certain team their own shared folder with only one member as the admin, add the following block: [development] path = /home/development comment = LetsCloud Development data writable = yes valid users = brittany mark laura admin users = taylor By now you have your Samba configured to share files in an environment. If you have any questions, leave them in the comments below.

Read more about: Data Management