Install Samba on Ubuntu: Configure SMB
The method for installing and configuring SMB (Samba) in Ubuntu is as follows:
- Open the terminal and install the Samba software package using the following command.
- Please install samba using the following command: sudo apt-get install samba
- After the installation is complete, edit the Samba configuration file.
- Open the smb.conf file in the /etc/samba directory using the nano text editor with superuser privileges.
- In the configuration file, you can set the following parameters to configure Samba:
- workgroup: set the name of the Samba workgroup.
- security:设置Samba的安全模式,可以选择为user、share或domain。
- Enable Ubuntu as a WINS server by setting it to yes.
- “hosts allow” and “hosts deny” can be used to allow or deny access to Samba shares from specific host IP addresses.
- valid users: designate which users are allowed to access the Samba shares.
- writable: Configure whether Samba share is writable.
- set the path for the shared file or directory.
- After completing the configuration, save and exit the configuration file.
- Create a folder or directory that needs to be shared.
- Create a new directory at /path/to/shared/folder using superuser privileges.
- Set the owner and permissions of the shared folder:
- Change the ownership of the shared folder to nobody and nogroup, then update the permissions to 777 for the shared folder.
- Create a Samba user and set a password:
- Add a new username to the Samba (SMB) password database.
- Restart the Samba service:
- Restart the smbd service using systemctl.
- On Windows or other devices, you can access shared files by entering the IP address of Ubuntu and the name of the shared folder.
This completes the process of installing and configuring SMB in Ubuntu.