What are the steps for setting up a Linux Samba server?

The steps to set up Linux Samba are as follows:

  1. Install Samba server software:
  2. Run the command on Debian/Ubuntu: sudo apt-get install samba.
  3. Execute the command “sudo yum install samba” on CentOS/Fedora.
  4. Create a shared directory.
  5. Create a folder using the mkdir command to serve as a shared directory, for example: sudo mkdir /home/share.
  6. Set up Samba.
  7. Open the Samba configuration file /etc/samba/smb.conf with sudo nano /etc/samba/smb.conf.
  8. Add the following at the bottom of the file:
    [share]
    comment = Shared Folder
    path = /home/share
    writable = yes
    guest ok = yes
    browseable = yes

    In which:
    [share] is the name of the shared folder
    comment is the description of the shared folder
    path is the path of the shared directory
    writable indicates whether the shared directory is writable
    guest ok indicates whether anonymous access is allowed
    browseable indicates whether it can be browsed

  9. Create Samba user:
  10. Create a Samba user using the smbpasswd command to allow access to shared directories, for example: sudo smbpasswd -a username.
  11. Enter password and confirm password.
  12. Start the Samba service:
  13. Execute the following command on Debian/Ubuntu: sudo service smbd restart.
  14. Run the command on CentOS/Fedora: sudo systemctl restart smb.
  15. Set up a firewall.
  16. If you have a firewall, you need to open the relevant ports for Samba (default ports are 137-139 and 445), for example:

    On Debian/Ubuntu, run the command: sudo ufw allow 137/udp
    On CentOS/Fedora, run the command: sudo firewall-cmd –add-service=samba –permanent, then run sudo firewall-cmd –reload

  17. Accessing Linux Samba through Windows.
  18. On Windows, open File Explorer, enter \\, and then press the Enter key.
  19. Enter your Samba username and password, then click on OK.

Now, you should be able to access the Samba shared directory on Linux from Windows.

bannerAds