How to install and configure Samba server in Ubuntu from terminal

Samba is one of the great alternatives that exist to share files in hybrid environments where Windows and Linux computers coexist. It is only necessary to install and configure the application in Ubuntu from the terminal.

Samba is nothing more than a communication protocol that allows computers with Windows operating system to connect to the Linux file system. In this way you can access Linux folders, files and network drives on Windows .

Requirements to install Samba on Ubuntu

  • Ubuntu operating system version 18.04 onwards
  • Administrator user permissions to access the Sudo application
  • Internet access
  • A terminal with Windows operating system to test the configuration

How to install and configure Samba

Having everything we need to start with the installation of the application, it is time to write the necessary commands. Try not to skip any steps.

Samba installation

  • Access Sudo and enter the command to start the Samba installation. sudo apt install samba samba-common python-dnspython .
  • To start the download, enter the letter S.

Verify the workgroup in the Windows terminal

  • One way to verify the workgroup is by right-clicking on the This computer icon and then choosing the Properties option.
  • Through the Windows Command Prompt you can verify the workgroup and domain by placing the command net config workstation . We will use it later to configure the smb.conf file.

Edit smb.conf file

  • Backs up the smb.conf file in case of failure. Type the command sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.orig .
  • Now you can edit the file. Set the secure file transfer settings with the secure file sharing  command
  • Set the unsafe anonymous value by setting Sudo unsecure Anonymous 
  • Create the directory where the files are shared by typing sudo mkdir -p / srv / samba / anonymous_shares 
  • Now add the access permissions to the files with the commands sudo chmod -R 0775 / srv / samba / anonymous_shares and sudo chown -R nobody: nogroup / srv / samba / anonymous_shares 

Modify the configuration file

  • Access the configuration file from an editor and modify the values vi: sudo vi /etc/samba/smb.conf and nano: sudo nano /etc/samba/smb.conf
  • Edit the directives in the Global section of the file. Set the following values: workgroup = WORKGROUP , netbios name = ubuntuX , security = user
    [Anonymous]
    comment = Anonymous File Server Share,  path = / srv / samba / anonymous_shares , browsable = yes , writable = yes , guest ok = yes , read only = no , force user = nobody
  • Finally save the changes made to the file with the key combination Ctrl + O and exit the editor.
  • To verify that everything works correctly, run the testparm command  .

Select shared folder

  • Select or create the folder that you want to be available for terminals with Windows 10.
  • Single click on the folder and then right click to select the Local Network Share option  .
  • The Folder Sharing window opens to enable the Share this folder option  . The other available options are automatically enabled and to finish press the Create Share button .
  • Finish the process by clicking on Add the permissions automatically.
  • The folder will be displayed with an arrow next to the folder icon to indicate that it is a shared folder. Do this same process with the folders you want to share.

Advantages of using Samba

Samba was created by Andrew Tridgell and he did it through reverse engineering. I create the compatibility of Unix environments using traffic grabbers very similar to Wireshark.

By using samba you choose what you want to share and how you want to share it. Initially it uses anonymous shares, where you share any content without restrictions and in other cases you can protect the files with access data .

 

Leave a Comment