In our last article, You will learn how to install and configure Samba on CentOS 7 for file sharing between other Linux and Windows systems.
Step: 1 Install Samba Server
Use below command to install samba with necessary packages.
# yum install samba samba-common samba-client -y
Step 2: Check Windows Workgroup
Before samba configurations, make sure Windows machine is in same workgroup.
open the cmd prompt in Windows machine and run the following command.
> net config workstation
Step 3: Samba Configuration
before configuration rename samba default configuration file /etc/samba/smb.conf as backup using below command.
# mv /etc/samba/smb.conf /etc/samba/smb.conf.default
Samba Anonymous File Sharing
Now create a shared folder on the server where all files/folders will be stored and set appropriate permissions on it and allow selinux for the samba configuration.
Run below commands
# mkdir -p /srv/samba/anonymous # chmod -R 0755 /srv/samba/anonymous # chown -R nobody:nobody /srv/samba/anonymous # chcon -t samba_share_t /srv/samba/anonymous
Now make following changes in new samba configuration file.
# vi /etc/samba/smb.conf
[global] workgroup = WORKGROUP server string = Samba Server %v netbios name = centos security = user map to guest = bad user dns proxy = no [Anonymous] path = /srv/samba/anonymous browsable =yes writable = yes guest ok = yes read only = no
Run below commant to verify samba configurations
Step 4: Start and Add Samba Services in firewall
Run below command to allow samba in firewall
# firewall-cmd --permanent --add-service=samba # firewall-cmd --reload
Run below command to start and enable samba services.
# systemctl start smb.service # systemctl enable smb.service # systemctl start nmb.service # systemctl enable nmb.service
Step 5: Access Shared folder
Now you can access the Centos shared folder from windows, open Run prompt by pressing win + r key on your keyboard then type \\centos and press enter key.
You will see Anonymous folder like below
Now you can add files/folders in this folder to share with other users.