Linux: Create a Samba share
Samba Server Setup
Samba Server Setup
The following steps needs to be executed in the server which will be used as Samba share with sudo or as root.
Create the share path
First we need to create a path that will hold our data.
mkdir /smbFix clients rights
Read / Write access to everyone.
chmod 777 /smbInstall Samba packages
We need to install those packages to make the samba server work.
yum install samba -yEdit smb.conf
Open /etc/samba/smb.conf and append the following to the end of the file and save changes.
[share]
browsable = yes
path = /smb
writable = yesTest configuration
This little tool tests smb.conf for errors
testparmCreate the Samba share user and password
useradd smbuser
smbpasswd -a smbuserStart the Samba service
systemctl start smb
systemctl enable smbSet Up the Samba Clients
The following steps need to be executed on the machines that will act as Samba clients towards the server.
sudo yum install cifs-utils -yMake a mount point
sudo mkdir /mnt/smbMount the Samba Share
sudo mount -t cifs //<SERVER_IP>/share /mnt/smb -o username=smbuser,password=<SMBPASSWD_PASS>Test creating a file
cd /mnt/smb
sudo touch 1.txtManaging permissions
If only one user needs read/write access, you can make them the owner of the mounted directory using the option uid=<linux_username>:
sudo mount -t cifs //<SERVER_IP>/share /mnt/smb -o uid=<unix_username>,file_mode=0664,dir_mode=0775,username=smbuser,password=<SMBPASSWD_PASS>If more than one user need read/write access, you can create a group, add the users to it:
addgroup new_group
adduser user1 new_group
adduser user2 new_group
adduser user3 new_groupthen mount the share using options gid, file_mode and dir_mode:
mount -t cifs //<SERVER_IP>/share -o gid=new_group,file_mode=0664,dir_mode=0775,username=smbuser,password=<SMBPASSWD_PASS>