Samba-based file sharing in Windows Linux
1. Set the shared directory, such as: D: // share
2. Create a working group windowslinux on "Network neighbors". The created working group will automatically share the "share" directory;
3. Create a new user "Linux" for Linux to operate shared files and set the corresponding permissions;
4. Add the "Linux" user access permission to the "share" directory;
1. Start the samba Service
[Root @ localhost ~] #/Etc/init. d/SMB start
Start the smb service: [OK]
Start nmb service: [OK]
Run the following command to check whether the server is running;
[Root @ localhost ~] # Pgrep smbd
[Root @ localhost ~] # Pgrep nmbd
View the SMB port number
[Root @ localhost ~] # Netstat-tlnp | grep SMB
TCP 0 0 0.0.0.0: 139 0.0.0.0: * Listen 10639/smbd
TCP 0 0 0.0.0.0: 445 0.0.0.0: * Listen 10639/smbd
If you have a firewall, you must open these two ports. Or clear firewall rules;
[Root @ localhost ~] # Iptables-f or
[Root @ localhost ~] #/Sbin/iptables-F
2. Modify the/etc/samba. conf file to implement an anonymous readable and writable
[Root @ localhost ~] # Cd/etc/samba
[Root @ localhost Samba] # mv smb. conf SMB. confbak
Write the following paragraph into smb. conf;
[Global]
Workgroup = windowslinux;
NetBIOS name = zhaoxr
Server String = Linux Samba server testserver
Security = Share
[Linuxsir]
Path =/share
Writeable = Yes
Browseable = Yes
Guest OK = Yes
[Global] This section is a global configuration and is required. There are the following rows;
Workgroup is the working group displayed in windows. Here I set windows Linux; (in upper case );
NetBIOS name is the name of the computer displayed in windows;
Server String is the description of the Samba server, which can be defined by yourself. This is not important;
Security is the authentication and login method. Here we use share. There are many authentication methods, one of which is also commonly used as the user authentication method. If share is used, you do not need to set the user and password;
[Linuxsir] the shared directory is displayed in windows;
Path = You can set where the directory to be shared is stored;
Whether writeable can be written. Here I set it to writable;
Whether browseable can be viewed or not. If browsed, we can see shared folders under the Working Group. If you do not want to display it, set it to browseable = No.
Guest OK anonymous users log on as guest;
3. Create a directory and authorize it;
[Root @ localhost ~] # Mkdir-P/share
[Root @ localhost ~] # ID nobody
Uid = 99 (nobody) gid = 99 (nobody) groups = 99 (nobody)
[Root @ localhost ~] # Chown-r nobody: Nobody/opt/linuxsir
1. View Linux sharing in Windows
After the Linux SAMBA service is started, enter "// ip address" in the browser to view the shared folder.
2. View windows sharing in Linux
A. Log in
Smbclient-l // ip-u Linux
B. Mount
Mount-T smbfs-O username = Linux, password =... // ip/share/mnt/windowsshare
You can see the content in/mnt/windowsshare.