samba file configuration for network sharing in ubuntu 22.04 using terminal / File sharing in Ubuntu 22.04
o configure Samba for network sharing on Ubuntu, you can follow the steps below:
- Install Samba: Open the terminal and type the following command to install Samba:
sudo apt-get install samba
- Create a shared folder: Create a folder that you want to share with other computers on the network. You can do this using the following command:
sudo mkdir /path/to/shared/folder
- Configure Samba: Open the Samba configuration file using the following command:
sudo nano /etc/samba/smb.conf
- Add a new section to the configuration file with the following details:
[ShareName]
path = /path/to/shared/folder
writeable = yes
guest ok = yes
create mask = 0777
directory mask = 0777
Replace "ShareName" with the name you want to give to the shared folder.
Save the changes to the configuration file and close it.
Restart Samba: Type the following command to restart the Samba service:
sudo systemctl restart smbd
- Allow Samba through the firewall: If you have a firewall enabled, you will need to allow Samba through it. Type the following command to allow Samba through the firewall:
sudo ufw allow samba
Once you have completed these steps, other computers on the network should be able to access the shared folder using the network path "\Ubuntu-IP-Address\ShareName" (replace "Ubuntu-IP-Address" with the IP address of your Ubuntu computer).
2 nd method :
here's a step-by-step guide on how to configure Samba with an example:
- Install Samba: Open the terminal and type the following command to install Samba:
csharpsudo apt-get install samba
- Create a shared folder: Create a folder that you want to share with other computers on the network. For this example, let's create a folder called "SharedDocs" in the home directory of the user "johndoe". Type the following command to create the folder:
bashsudo mkdir /home/johndoe/SharedDocs
- Grant permission to the shared folder: You need to grant permission to the shared folder so that other users can access it. Type the following command to give permission to the "johndoe" user:
bashsudo chown -R johndoe:johndoe /home/johndoe/SharedDocs
- Configure Samba: Open the Samba configuration file using the following command:
bashsudo nano /etc/samba/smb.conf
- Add a new section to the configuration file with the following details:
java[SharedDocs]
path = /home/johndoe/SharedDocs
valid users = @smbgrp
force group = smbgrp
create mask = 0664
directory mask = 0775
read only = no
Replace "SharedDocs" with the name you want to give to the shared folder. "smbgrp" is the name of the group that will have access to the shared folder. You can replace this with a group name of your choice. "create mask" and "directory mask" are file permission settings.
Save the changes to the configuration file and close it.
Create a Samba user: Type the following command to create a Samba user "johndoe":
csssudo smbpasswd -a johndoe
You will be prompted to enter a password for the new user.
- Add the Samba user to the Samba group: Type the following command to add the Samba user "johndoe" to the "smbgrp" group:
sudo usermod -aG smbgrp johndoe
- Restart Samba: Type the following command to restart the Samba service:
sudo systemctl restart smbd
- Allow Samba through the firewall: If you have a firewall enabled, you will need to allow Samba through it. Type the following command to allow Samba through the firewall:
sudo ufw allow samba
Once you have completed these steps, other computers on the network should be able to access the shared folder using the network path "\Ubuntu-IP-Address\SharedDocs" (replace "Ubuntu-IP-Address" with the IP address of your Ubuntu computer). They will need to enter the Samba username and password that you created to access the shared folder.
Comments
Post a Comment