Operating Environment: CentOS 6.5 64bit
What files are shared between Linux and Linux? NFS, Windows, and Windows? The file sharing function is OK. What about Windows and Linux?
This is what we will talk about in this section-samba.
Check whether samba is installed
# rmp -qa|grep samba
If installed, the following information is displayed,
samba4-libs-4.0.0-58.el6.rc4.x86_64samba-common-3.6.9-168.el6_5.x86_64samba-winbind-3.6.9-168.el6_5.x86_64samba-client-3.6.9-168.el6_5.x86_64samba-3.6.9-168.el6_5.x86_64samba-winbind-clients-3.6.9-168.el6_5.x86_64
Otherwise, use
# yum install smaba
Install samba.
Configure samba
Set startup
# chkconfig smb on# chkconfig nmb on
You can also use the setup command to configure the startup service on the page,
# setup
Create an smb User to access Linux shared files
# Useradd smb # new user # smbpasswd-a smb # Change Password
At this time, the/home directory will add an smb User. The Linux user directory can be directly shared to Windows. To share other files, follow Step 3 to configure the file. If you don't need it, you can also delete smb users,
# Smbpasswd-x smb # delete an smb User
Samba configuration file.
[Tmp] comment = Tmp Directoriespath =/tmp # shared Linux directory public = no # directory not public writeable = yes # writable browseable = yes # readable valid users = smb # accessed users, you can also use the existing
Allow smaba to pass through the firewall
Samba must pass through the firewall. Therefore, three methods are provided as follows:
Method 1
# system-config-firewall
Method 2
Configure the/etc/sysconfig/iptables file and add
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
Allow port 139 445 137 to pass through. Restart the firewall after configuration,
# /etc/rc.d/init.d/iptables restart
Method 3
Simply shut down the firewall,
# Service iptables stop # temporarily disable # chkconfig iptables off # permanently disable
Disable SELINUX
# vim /etc/selinux/configSELINUX=permissive
In this case, you need to restart the system,
# reboot
Start samba
# Service samba start # service samba restart # restart
You can use
# service samba status
View the samba startup status.
Windows Access
First, check the network IP address of the Linux virtual machine,
# ifconifgeth0 Link encap:Ethernet HWaddr 00:0C:29:FD:DC:43 inet addr:192.168.56.58 Bcast:192.168.56.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fefd:dc43/64 Scope:Link
In Windows, use Win + R to open the Run window, and enter
\\192.168.56.58
To access the shared directory in Linux.
Use
# smbstatus
View the connection status.
File Access permission:
If you cannot copy files from the shared directory in Windows, the shared directory may have insufficient write permissions for smb users. You can change the dir directory permission by using chmod 777-R dir in Linux. The/tmp directory is shared in this article because the/tmp directory is more open to all users.
Reference
- Http://www.livingelsewhere.net/tag/unix-linux-samba-ftp-smb-cifs/
- Http://www.tangrucheng.com/centos6-5-setup-configure-samba.html