This will install the samba server on ubuntu, which allow files to be shared between windows and our ubuntu server.
Installing samba server (if not done at ubuntu server installation)
If you haven’t followed the previous articles which automatically installs the samba server, you can install it now by:
$ sudo apt-get install samba smbfs
About samba configurations
There are many ways of doing this, it really depends on your situation.
I’m going to create two directories, “backup” and “shared” and I’ll assign them to a new user called fab_samba.
The fab_samba user will have no login capabilities and will be purely used for all our windows computers to login to the two directories above.
Create the fab_samba user in ubuntu and in samba
First we need to make sure that the user we are trying to create doesn’t already exist. The command below will show a list of all users, make sure the username you want to use doesn’t appear there:
$ sudo cat /etc/passwd
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
fab:x:1000:1000:Fabricio Sanchez,,,:/home/fab:/bin/bash
// In the output above, usernames that exist are: games, man, lp, mail, news, fab
Create the new user:
$ sudo useradd fab_samba
Then you can check that the user was created:
$sudo cat /etc/passwd
fab:x:1000:1000:Fabricio Sanchez,,,:/home/fab:/bin/bash
fab_samba:x:1001:1001::/home/fab_samba:
Now add the user to samba:
$ sudo smbpasswd -a fab_samba
New SMB password: <-- type new password (used when connecting from windows)
Retype new SMB password: <-- confirm password above
Added user fab_samba.
Optional step: remove shell login for user fab_samba, stops the user being able to login into the ubuntu server.
$ sudo nano /etc/passwd
// Add the following to the last line where user fab_samba is: /bin/false
// Changing:
fab_samba:x:1001:1001::/home/fab_samba:
// to:
fab_samba:x:1001:1001::/home/fab_samba:/bin/false
(Please note the 1001 and /home/fab_samba might be different in your system, so don't change those values, just add /bin/false at the end)
Confirm the change:
$ sudo cat /etc/passwd
fab:x:1000:1000:Fabricio Sanchez,,,:/home/fab:/bin/bash
fab_samba:x:1001:1001::/home/fab_samba:/bin/false
Re-process the password file (because of the manual change above):
$ sudo pwconv
Create the two directories to share with windows
Make the two directories:
$ mkdir backup
$ mkdir shared
Ensure that they are owned by the fab_samba user so that windows users can read/write to it.
$ sudo chown fab_samba:fab_samba backup
$ sudo chown fab_samba:fab_samba shared
You can check that ownership of the directories is now changed to fab_samba:
$ ls -al
drwxr-xr-x 14 fab fab 4096 Mar 9 12:10 .
drwxr-xr-x 3 root root 4096 Jan 11 12:29 ..
drwxrwxr-x 2 fab_samba fab_samba 4096 Jan 26 13:08 backup
drwxrwxr-x 2 fab_samba fab_samba 4096 Mar 9 11:53 shared
Configure samba’s smb.conf
Make a backup copy of the samba configuration file before editing:
$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
Edit the samba configuration file to add the new directories:
$ sudo nano /etc/samba/smb.conf
Add the following at the end of the file, ensure there is a blank line between blocks “[dir_name]”:
[backup]
path = ~/backup
valid users = fab_samba
read only = no
[shared]
path = ~/shared
valid users = fab_samba
read only = no
(Note: it is also important to ensure that the workgroup = WORKGROUP in the smb.cong matches your windows workgroup, in my case it is WORKGROUP so no change needed)
// You can optionally run the following command to ensure the smb.conf file is correctly fomratted:
$ testparm
// Save the file and restart the samba server:
$ sudo service smbd restart
smbd stop/waiting
smbd start/running, process 19825
Login from windows
Open a Windows Explorer and go to Network > find your ubuntu sever USERVER in my case
You should be presented with a login box: type your username (fab_samba in my case) and password and presto, you should have access to your directories.

As an extra test, create a text file from windows and from ubuntu and make sure it is correctly appearing on the other machine.
Delete them and make sure everything is updated.
![]()
