Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Linux file sharing to Windows using Samba
1. Linux file sharing to Windows using Samba
Warning: These instructions are for a test/development machine for which you are the only user aside from system process users.
One way to share files between Windows and Linux is with Samba.
2. Install Samba
The following Linux command(s) install Samba.
sudo yum -y install samba samba-client samba-common
3. Start Samba
The following Linux command(s) start the Samba services.
sudo systemctl start smb.service
sudo systemctl start nmb.service
4. Enable Samba
The following Linux command(s) enable the Samba services to start on boot.
sudo systemctl enable smb.service
sudo systemctl enable nmb.service
5. Configure the firewall
The following Linux command(s) configure the firewall to allow Samba access.
sudo firewall-cmd --permanent --zone=public --add-service=samba
sudo firewall-cmd --zone=public --add-service=samba
6. Reload the firewall settings
Use the following command to .
The following Linux command(s) reload the firewall settings.
sudo firewall-cmd --reload
7. Samba users
Samba has users separate from Linux (and Windows) though I have found it easier to use the same user names on Linux, Samba and Windows.
To make it easier, the following is done.
The Windows user name is robin (or your user name)
The Linux user name is robin.
The Samba user name is robin.
All of the passwords are the same.
8. Samba user
Use the following command to .
The following Linux command(s) create a Samba user called
robin and provide a password for that user.
sudo smbpasswd -a robin
9. Create folder to share
Rather than using the home folder, I often use a folder from the root - but the permissions need to be set appropriately.
The following Linux command(s) create a root folder
rms and assign proper permissions.
sudo mkdir /rms
sudo chmod -R 777 /rms
sudo chown -R robin:rmsgroup /rms
Do not use sudo to do the following.
10. Workgroup
In Windows do the following at the Windows command line prompt.
The following
Windows command(s) determine the workstation domain of the computer.
net config workstation
On
2019-08-09 the output was as follows.
Computer name \\AX8
Full Computer name AX8
User name Robin
... omitted ...
Workstation domain RENDANT
Logon domain AX8
The Samba workgroup name should be the same as the Windows workstation domain name.
11. Configure Samba shares
The Samba share for
/rms now needs to be configured.
The following Linux command(s) edit the Samba share configuration file.
sudo nano /etc/samba/smb.conf
Then make the following changes in the editor change the settings for
workgroup , add the setting for
server string and then add the
rms settings at the end of the file.
... omitted ...
workgroup = RENDANT
... omitted ...
[rms]
comment = rms
guest ok = yes
path = /rms
read only = no
12. Check the Samba changes for issues
The following Linux command(s) check the Samba changes for issues.
testparm
13. Restart Samba services
The following Linux command(s) restart the Samba services.
sudo systemctl restart smb.service
sudo systemctl restart nmb.service
14. SELinux
As a security feature, SELinux prevents any viewing of a share automatically. For Samba access, this needs to be addressed. The following command necessary for the Windows machine to temporarily see the Centos share.
The
setsebool command switches on and off the protection of SELinux.
The following Linux command(s) tell SELinux to allow other machines to access Samba shares.
sudo setsebool -P samba_export_all_rw on
Note: This command can take 15 seconds to complete.
15. Windows drive map access
The following assumes that you have some knowledge of Windows machines and networks on which your Windows machines reside.
The following
Windows command(s) access the Linux share
rms from Windows and mount it as drive
P: using the host name
CENT1.
net use P: \\CENT1\rms
16. Linux IP
If the machine name for
CENT1 is not properly set, the IP address can be used.
The following Linux command(s) determine the IP address of
CENT1 from
CENT1 using a Linux command.
ifconfig
On
2019-08-09 the output was as follows.
enp2s0: flags=4163 mtu 1500
inet 192.168.100.121 netmask 255.255.255.0 broadcast 192.168.100.255
... omitted ...
The IP address here is
192.168.100.121.
17. DHCP
Note: I use DHCP for machines to get an IP address and name from the network router and have the router assign each machine, based on MAC address, a specific pre-determined IP address. Details are beyond the scope of the present discussion.
18. Ping host from Windows
The following
Windows command(s) see if the machine name
CENT1 is accessible from Windows.
ping CENT1
On
2019-08-09 the output was as follows.
Pinging CENT1 [192.168.100.121] with 32 bytes of data:
Reply from 192.168.100.121: bytes=32 time=1ms TTL=64
... omitted ...
Note that this may not work for you.
19. Ping IP from Windows
The following
Windows command(s) see if the machine IP
192.168.100.121 is accessible from Windows.
ping 192.168.100.121
On
2019-08-09 the output was as follows.
Pinging 192.168.100.121 with 32 bytes of data:
Reply from 192.168.100.121: bytes=32 time=1ms TTL=64
... omitted ...
20. Windows drive map
The following
Windows command(s) access the Linux share
rms from Windows and mount it as drive
P: using the host name
CENT1.
net use P: \\192.168.100.121\rms
The following
Windows command(s) remove the connection of drive
P:.
net use P: /delete /yes
The following
Windows command(s) show if the Linux share
rms on
CENT1 is available.
dir P:\
If this does not work, something needs adjusted in order for it to work.