
Samba Server on Ubuntu 24.04: Installation and initial configuration
Whether from a home computer or a small office to a server in a medium or large company, one of the most basic and essential services that anyone could want or need, is without a doubt, the power share files internally. Since, it is not always the most optimal and safest thing to use the Internet network (email services, online storage platforms or instant messaging applications) to transfer any type of documents to others.
And for this reason, in the past we have shared useful and complete tutorials or small quick guides to solve this essential desire or important need in various ways. But, since, when it comes to store and share files within a network, the use of the Samba protocol is the best known, functional and universally used, both for Windows, macOS and Linux, today we will take the opportunity to update our previous quick guide in this regard based on Ubuntu 14.10. So, without further ado, below we will teach you directly and simply about «how to implement a simple Samba Server in Ubuntu 24.04».
But, before starting this new quick guide on «how to implement a simple Samba Server in Ubuntu 24.04», we recommend you explore the previous related post with this topic, at the end of reading it:
Samba is an implementation of SMB-compatible services and protocols (now called CIFS) with which Windows computers communicate with each other: It was developed by Andrew Tridgell through reverse engineering, using Wireshark (formerly known as Ethereal) style traffic grabbers to offer compatibility in *nix environments, something that was needed to not be isolated in corporate and educational environments in which several platforms usually coexist (Windows, Linux, Mac OS X).
Samba Server on Ubuntu 24.04: Installation and initial configuration
Basic and essential considerations
Since this is a quick guide, we will not delve into important aspects that must be known and mastered in advance. For example: What is the fstab file and how is it used to automatically mount partitions or disks on Ubuntu Linux?, and What are the Samba command options and what are they for? Therefore, below we leave you the relevant links to take into account to efficiently complement this information:
- Samba Documentation (Official Website)
- Configure Samba as a File Server on Ubuntu
- Manual (Help) on Fstab in Ubuntu
- Fstab file manual on Wiki Arch
- Manual (Help) on the Mount command in Ubuntu
- Manual (Help) on the Samba smb.conf file in Ubuntu
- Debian Administrator's Manual on Samba Server
Steps to implement a simple Samba Server in Ubuntu 24.04
Stage 1: Installing packages
On a desktop computer or network server with Ubuntu 24.04, the first thing we will have to do is install Samba with the following command order:
sudo apt install samba samba-client -y # Paquetes de samba esenciales
smbd -V # Validar versión de Samba instalada
sudo apt install cifs-utils dosfstools exfat-fuse exfatprogs fuse3 libsmbclient ntfs-3g smbclient #Paquetes extras útiles y necesarios
Stage 2: Configure a system folder to use as a public folder
sudo mkdir /opt/publico #Crear carpeta “público” en la carpeta “/opt” del sistema operativo.
sudo chmod -R 777 /opt/publico/ #Dar permisos totales a carpeta “público”.
sudo chown nobody:nogroup -R /opt/publico/ #Asignar carpeta “público” a usuario y grupo genérico.
Step 3: Configure an NTFS formatted disk/partition (sdb1) to use as a public folder
sudo mkdir /media/disk2 #Crear carpeta “media” en la carpeta “/media” del sistema operativo.
sudo mount -t ntfs /dev/sdb1 /media/disk2 #Probar montaje de partición/disco “sdb1” en la carpeta asignada.
sudo umount /dev/sdb1 #Desmontar partición/disco “sdb1”
If everything has gone well, we continue with the following steps:
sudo nano /etc/fstab #Editar archivo fstab
We insert the following line at the end of the file:
/dev/sdb1 /media/disk2 ntfs-3g defaults 0 0 #Montaje automático de la partición/disco “sdb1” en el arranque.
We save the changes and run the following command to test the mount again:
sudo mount -a #Ejecutar montaje manual de todas las particiones/discos dentro del archivo “fstab”.
If everything goes well up to this point, it is recommended to restart the computer/server and try automatic mounting, locally and via network, after the server operating system is active.
Step 4: Set up a minimal samba file with both shares
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.1.bck #Respaldar el archivo de configuración de samba.
sudo nano /etc/samba/smb.conf #Editar el archivo de configuración actual de samba.
We empty the file completely and add the following content:
#======================= Global Settings =======================
[global]
workgroup = WORKGROUP
security = user
netbios name = SAMBA-PUBLICO
server string = Samba 4.x
hosts allow = 192.168.250.0/255.255.255.0
log level = 3
map to guest = bad user
[PublicoServ]
comment = Data compartida sobre Disco principal del Servidor
path = /opt/publico/
browsable = yes
writable = yes
guest ok = yes
guest only = yes
force create mode = 0777
force directory mode = 0777
read only = no
force group = nogroup
force user = nobody
[PublicoDisk]
comment = Data compartida sobre Disco adicional del Servidor
path = /media/disk2/
browsable = yes
writable = yes
guest ok = yes
guest only = yes
force create mode = 0777
force directory mode = 0777
read only = no
force group = nogroup
force user = nobody
Step 5: Test Share Configuration and Availability
sudo testparm #Probar configuración exitosa del archivo de Samba.
sudo systemctl restart smbd nmbd #Reiniciar los Servicios de Samba y NetBIOS.
After this, and if any error found has been previously solved, all that remains is to try from one or more computers on the network, with Windows and GNU/Linux, to be able to access said shared resources anonymously (guests), that is, , without passwords and read and write restrictions.
Screenshots of some parts of the complete installation and configuration process
Summary
In summary, and as we can see with this short and useful guide, installing and configuring a simple «Samba Server on Ubuntu 24.04» It is possible with a few tips and quick steps from the terminal of your operating system. And since, on this occasion, we only configure a public folder (without restrictions for any user on the network), soon we hope to offer you a second part with the configuration of folders for users or groups of users predefined by password. And in case you know other useful tips or advice to improve or complement this quick guide, we invite you to tell us about them via comments for everyone's knowledge and usefulness.
Lastly, remember to share this fun and interesting post with others, as well as visit the beginning of our «site" in Spanish. Or, in any other language (just by adding 2 letters to the end of our current URL, for example: ar, de, en, fr, ja, pt and ru, among many others) to find out more current content. Additionally, we invite you to join our Official Telegram channel to read and share more news, guides and tutorials from our website. And also, the next Alternative Telegram channel to learn more about the Linuxverse in general.