Skip to main content

Samba file server Ubuntu/Debian

Updated this week

Samba is an open-source software suite that enables file and print sharing between systems running Windows, Linux, and macOS over a network. It implements the SMB (Server Message Block) and CIFS (Common Internet File System) protocols, allowing seamless integration with Windows-based networks. Samba provides tools for managing user authentication, file permissions, and resource sharing, making it ideal for both small networks and enterprise environments.

Installation

1. System update

First of all, update your operating system by running this command:

apt update && apt upgrade -y

2. Installing Samba

Run the following command to install Samba:

apt install samba -y

Verify if Samba was installed on the server:

whereis samba
samba -V

If you see the output, the Samba application is installed on your server:

Lastly, check if it is up and running:

systemctl status smbd
<a href="https://community.time4vps.com/uploads/editor/cq/s6n59xp0730z.png" rel="nofollow noopener noreferrer" target="_blank">https://community.time4vps.com/uploads/editor/cq/s6n59xp0730z.png</a>

3. Setting up Samba

Once Samba is installed, there are configuration settings that need to be adjusted. Firstly, create a shared folder:

mkdir /home/username/foldername/

Use your username and create a new folder with any name you prefer (the user should already exist).


Secondly, configure the Samba configuration file, for this tutorial, nano editor will be used:

nano /etc/samba/smb.conf

At the bottom of the file, paste in the following lines:

[foldername]
comment = Samba on Ubuntu
path = /home/username/foldername
read only = no
browsable = yes
valid users = @username

Correct the lines, so they match with your server. [foldername] use your own created directory name, "comment" - a simple description of the server, "path" - use the path you have created a directory earlier.


Add the user to the Samba service:

smbpasswd -a username

Instead of username use your created user in the system.


Restart Samba service

systemctl restart smbd

Update the Firewall of your server:

ufw allow samba

Also if folder was created with the "root" user, but you prefer to log in with any other user, update permissions:

chown username:username -R /home/username/foldername/

Instead of username use your created user in the system.

4. Test the Samba application

If you are using Windows, navigate to "My Computer" and map the drive:

Write in your server's hostname or IP address and specify the path.

For example, in this tutorial, it would be:

\\hostname.tld\storage

When prompted for a login, select "Registered user" and write in the username and password that you created with smbpasswd command.

If you're using Linux, access your file manager application and navigate to "Other locations". You need to write in additional characters:

smb://hostname.tld/storage


Conclusion

After completing the installation and configuration, you are ready to use the server for a file sharing inside your file manager's location. The server can be used on multiple devices at once and does not require login everytime, which speeds up the productivity. Samba can be also used on smart phones with IOS and Android operating systems. You can relate on these guides how to connect to the Samba application which is installed on your server:

Did this answer your question?