SAMBA SERVER 2.0 #server

 To share a folder on a LAN using Samba on a Linux system, follow these steps:


1. **Install Samba**: If it's not already installed, you need to install Samba. Open a terminal and run:


   ```bash

   sudo apt update

   sudo apt install samba

   ```


2. **Create a Directory to Share**: Create the directory you want to share, if it doesn't exist. For example:


   ```bash

   sudo mkdir -p /srv/samba/share

   sudo chmod 2775 /srv/samba/share

   sudo chown nobody:nogroup /srv/samba/share

   ```


3. **Configure Samba**: Edit the Samba configuration file to add your share.


   Open the Samba configuration file in a text editor:


   ```bash

   sudo nano /etc/samba/smb.conf

   ```


   Add the following configuration at the end of the file:


   ```ini

   [share]

   path = /srv/samba/share

   browseable = yes

   read only = no

   guest ok = yes

   create mask = 0660

   directory mask = 2770

   force user = nobody

   force group = nogroup

   ```


   This configuration sets up a share called "share" that allows guest access and read/write permissions.


4. **Restart Samba Service**: Restart the Samba services to apply the changes:


   ```bash

   sudo systemctl restart smbd

   sudo systemctl restart nmbd

   ```


5. **Allow Samba Through the Firewall**: If you have a firewall enabled, you need to allow Samba traffic. For example, if you are using `ufw`:


   ```bash

   sudo ufw allow 'Samba'

   ```


6. **Access the Share from Another Machine**: From another machine on the same network, you can access the shared folder. For example, from a Windows machine, you can open File Explorer and enter the following in the address bar:


   ```

   \\<IP_ADDRESS_OF_SAMBA_SERVER>\share

   ```


   Replace `<IP_ADDRESS_OF_SAMBA_SERVER>` with the actual IP address of your Linux machine.


**Optional Steps:**


- **Creating Samba Users**: If you want to create Samba users with passwords, you can do the following:


  ```bash

  sudo smbpasswd -a <username>

  ```


  Add the user to the Samba password database and set a password for the user.


- **Securing the Share**: If you want to secure the share so that only specific users can access it, update the share definition in `smb.conf` as follows:


  ```ini

  [share]

  path = /srv/samba/share

  browseable = yes

  read only = no

  guest ok = no

  valid users = <username>

  ```


  Replace `<username>` with the actual user you created.


- **Reload Samba Configuration**: After making changes to the configuration file, reload the Samba configuration:


  ```bash

  sudo systemctl reload smbd

  ```


By following these steps, you should be able to share a folder on your LAN using Samba on a Linux system.

Comments

Popular posts from this blog

From cool things #1 Hosting a website on apache ubuntu server and you can host directory and files to just remove index. html