Setting Up SMB Service on Ubuntu 18.04
Setting Up SMB Service on Ubuntu 18.04
Table of Contents
- Install SMB and enable the SMB server and restart it.
- Add an SMB user.
Edit the SMB configuration file.
Permission configuration:
- Read (R)
- Read/Write (RW)
- Firewall configuration.
- Visit the SMB server on your local network.
Install SMB server
sudo apt update
sudo apt install samba
sudo systemctl enable smbd
sudo systemctl restart smbd
Add an SMB user
sudo smbpasswd -a username
Edit the SMB configuration file
sudo vim /etc/samb/smb.conf
[WiKiFolder_for_Client]
comment = Shared Folder
path = /home/username/wiki
browseable = yes
valid users = @username
[WiKiFolder_for_Client]
: The name of the shared folder being defined.
comment = Shared Folder
: Description of the shared folder.
path = /home/username/wiki
: Specifies the path of the shared folder.
browseable = yes
: Allows the shared folder to be visible on the network.
valid users = @username
: Specifies that only users belonging to the username
group can access the shared folder.
[WiKiFolder_for_Client]
comment = Shared Folder
path = /home/ccdcam/wiki
browseable = yes
valid users = ccdcam
writable = yes
valid users = username
: Specifies that only users belonging to the username
group can access the shared folder.
writable = yes
: Allows users to write to the shared folder.
Firewall configuration
Allowed th 445/tcp
sudo ufw allow 444/tcp
Accessing the SMB Share on your local network
For Windows:
Enter \\<serverIPaddress>
in the file explorer's address bar, then proceed to log in.
Viewing the SMB User List
Using the
pdbedit
Command:To list the users in Samba, enter the following command in the terminal:
sudo pdbedit -L -v
This will display detailed information about Samba users, including usernames, UID, GID, home directories, and more.
Using the
getent
Command:You can also list Samba users using the
getent
command. Enter the following command:getent passwd | grep '/bin/false'
This will display the usernames of Samba users and other relevant information.
Deleting an SMB User
To delete a user in Samba, you can use the pdbedit
command. Here are the steps to delete an SMB user:
sudo pdbedit -x username
You will be prompted to confirm the deletion. Enter y
to confirm.
After the deletion is complete, restart the Samba service to apply the changes:
sudo systemctl restart smbd