Linux Fileserver

Installation file server

2 possibilities: NFS versus Samba
If you will ever attach Windows PC's to your network, use Samba. If not NFS is easier.



Download Samba

sudo apt-get install samba

Make a backup of the standard configuration file (/etc/samba/smb.conf)

cd /etc/samba/smb.conf
sudo cp smb.conf smb.conf.orig

Add the shares to the config file

Underneath == Global Settings ==, in the section [global], add:
hosts deny = ALL
hosts allow = 192.168.1 127.
to manage the security: only hosts in the 192.168.1.x and the 127.x.x.x range are allowed.
Underneath == Share definitions ==, add a section for each share you want to make. Eg.:
comment = Test
path = /home/export
valid users = usernames
public = no
writable = yes
printable = no
The name of the section (in between [ ]) is also the name of the share! So this is the name you'll have to use later to mount the share!

Check the validity of the changes in the config file


Load the new config file for Samba

sudo /etc/init.d/samba reload
(If Samba wasn't started yet: sudo /etc/init.d/samba start)

Add Samba user(s)

The user also has to be a user of the Linux server. (If not present yet, you can add it with 'adduser username'.)
Add the user with:
smbpasswd -a username
Enter the Samba password for the user. This doesn't have to be the same password as the user on the server.
You can list the samba users with pdbedit -w -L.

Add the share on the client

Check Samba shares on client:
smbclient -L server-address
If not installed: apt-get install smbfs
Mount the share:
sudo mount -t cifs (or smbfs) -o user=server_user,password=pw_server_user //server/share /clientshare
Or add the mount to /etc/fstab, depending on version (check with smbclient -V):
Version 3.5.8: server:/servershare(sectionname) /clientshare smbfs defaults,username=server_user,password=pw_server_user 0 0
Version 3.4.7: //server/servershare(sectionname) /clientshare smbfs defaults,username=server_user,password=pw_server_user 0 0

It is possible that the share has only read-/write right for root.
In that case, you can specifiy which user/group has rights:
sudo mount -t cifs -o user=server_user,password=pw_server_user,uid=client_user,gid=client_group //server/share /clientshare
Or in /etc/fstab:
server:/servershare /clientshare cifs username=server_user,password=pw_server_user,_netdev,uid=client_user,gid=client_group 0 0


Check Samba processes: ps -aux.
The Samba processes are smbd (the real samba server service) and nmbd (kind of WINS server: gives kind of DNS names to IP-adresses)
Check Samba version: /usr/sbin/smbd -V (info smbd gives an explanation)
Location configuration files: /etc/samba
Scripting: etc/init.d/samba reload (read config files without stopping service), restart, start, stop

Websites Samba


NFS 3 server

Installation of NFS server: sudo apt-get install nfs-kernel-server
Add shares to the file /etc/exports by adding
/home/user/data, sync, no_subtree_check, root_squash)
## root_squash (default): we don't want to trust any requests made as root on the client. To turn off: no_root_squash)
## secure (default): only listen to requests coming from ports 1-1024 on the client. (Ports 1-1024 are secure ports, reserved for root's use, so that a malicious non-root user on the client cannot come along and open up a spoofed NFS dialogue on a non-reserved port.)
sudo exportfs -ra
sudo /etc/init.d/nfs-kernel-server restart

NFS 3 client

Installation of the nfs client: sudo apt-get install nfs-common
Configuration file /etc/fstab /home/peter/Afbeeldingen nfs rsize=8192,wsize=8192,timeo=14,intr
## The first location is the location on the server, the second one is on the client

NFS 4 server

NFS 4 client

Useful links

Handleiding installatie (zowel nfs3 als nfs4):

Voor tips over beveiliging:

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License