0% found this document useful (0 votes)
20 views2 pages

Configure Samba File Sharing on Linux

This document provides instructions for configuring Samba file sharing on a server. It describes installing Samba, creating a new configuration file, restarting Samba, adding a system user to Samba, giving that user ownership of the share folder, and connecting to the share from another device. The configuration file format is also shown, including options for the share name, path, permissions, and enabling a recycle bin feature.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Configure Samba File Sharing on Linux

This document provides instructions for configuring Samba file sharing on a server. It describes installing Samba, creating a new configuration file, restarting Samba, adding a system user to Samba, giving that user ownership of the share folder, and connecting to the share from another device. The configuration file format is also shown, including options for the share name, path, permissions, and enabling a recycle bin feature.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Samba File Share Settings

- Samba is named after the Server Message Block (SMB) protocol. SMB is a Microsoft protocol for file and printer sharing
across a network
- For more details on any of these commands, be sure to read the man pages from the command line for each command,
e.g. man smbpasswd, man pdbedit, etc...
- Samba log files are saved at /var/log/samba. These might be useful to review if you are having any problems
- Samba uses port 445. Be sure to enable this port in your firewall

Sequence:

1. Install samba
sudo apt install samba -y

This will install the SAMBA file server to your server

2. Create new config file


cd /etc/samba
sudo mv [Link] [Link]
sudo nano [Link]

Samba comes with a lengthy default configuration file ([Link]), which lists all of its options. Rather than trying to edit
this, it is easier to back it up and make a new one. Here we move into the /etc/samba directory and rename the config
file to [Link]. We then use the nano text editor to create and open a new file.
You will need to use sudo when creating the new config file. The config lines to be added are listed on page 2 below

3. Restart samba
sudo service smbd restart

To have Samba use the new config file you must restart it

4. Add system user to smbpasswd


sudo smbpasswd –a jupiter

To use the Samba file share, a Samba account needs to be created for the Linux system users. You also have the option
of adding a password when adding the user. To set up an open file share (no password required), do not enter any
password when asked to do so.
To see which users have been added to smbpasswd, run sudo pdbedit –L -v

5. Give system user ownership over /srv


sudo chown –R jupiter:jupiter /srv

In this video, we use /srv as the folder for the file share. By default, this is owned by the root user. To allow the jupiter
user to create and delete files on it, use chmod to give jupiter ownership over the whole folder

6. Connect to the file share from your laptop, desktop or phone


From a Windows 10 laptop:
1. Open File Explorer and click This PC
2. Click Map Network Drive
3. Enter the Drive Letter you want to use and the folder. Be sure to add the \\ before the server IP address
4. Tick the option to reconnect at sign in. This remembers this file share for when you shut down and start up your
laptop again
5. Click Finish. The network file share should open straight away for you.
/etc/samba/[Link] format

[sharename]
path = /srv
read only = no
force user = jupiter
force group = jupiter
vfs object = recycle
recycle:repository = /srv/RecycleBin
recycle:keeptree = yes
recycle:versions = yes
recycle:exclude = *.tmp, *.temp
recycle:exclude_dir = RecycleBin

Share specific options control the behaviour of the file shares you configure. You can have more than
one file share, pointing to different paths for example.
[sharename]
You connect to the file share by browsing to \\server_ip_address\sharename, i.e.
[Link]\files
path The location of the folder on the server being used as the file share.

read only This sets whether the user is able to write to the share

force user Set the user account to be used when working (reading/writing) with files on the file share

force group Set the group to be used when working (reading/writing) with files on the file share

vfs object Enable the Recycle Bin module

recycle:repository Set the path/folder for where deleted items will go


If a deleted item is within a folder, that folder will be recreated within the Recycle Bin. This keeps the
recycle:keeptree
folder structure, making it easier for you to see where deleted files were stored before deletion
recycle:versions If two files with the same name are deleted, two versions will be created in the Recycle Bin

recycle:exclude File types to be excluded. These will not go to the Recycle Bin and will be permanently deleted

recycle:exclude_dir Folders to be excluded from the Recycle Bin. You need to include your Recycle Bin folder here

Common questions

Powered by AI

Creating a new configuration file for Samba, instead of modifying the default lengthy smb.conf file, avoids complications and makes it easier to implement specific settings and changes .

Restarting the Samba service is necessary after modifying the smb.conf file to apply and activate the new configuration settings .

Mapping a network drive in Windows facilitates quick and consistent access to a Samba share by assigning it a drive letter. Steps include opening File Explorer, selecting "Map Network Drive," entering the server and share path, and choosing to reconnect at sign-in .

The 'force user' and 'force group' settings in the smb.conf file specify the default user account and group to be used for operations involving reading or writing files on the Samba share. This controls access and permissions .

The 'recycle:keeptree' setting maintains the directory structure of deleted items in the Recycle Bin. This makes it easier to track where files were originally located, aiding in file recovery and organization .

The 'recycle:repository' option in Samba's smb.conf file specifies the directory where deleted files are stored, functioning like a Recycle Bin. This prevents accidental loss of files by allowing recovery of deleted items .

The 'read only' setting in the smb.conf file determines the write permissions for a Samba share. If set to 'no', it allows users to write to the share, otherwise it restricts it to read-only access .

Samba is a system named after the Server Message Block (SMB) protocol, a Microsoft protocol used for file and printer sharing across a network .

Samba log files are stored at /var/log/samba and reviewing these logs can be useful for identifying and resolving problems with the Samba service .

Excluding certain files (e.g., *.tmp, *.temp) and directories from the recycle bin means they bypass the Recycle Bin and are permanently deleted. This reduces the storage used for temporary or non-essential files but requires caution to avoid accidental data loss .

You might also like