File sharing configuration between Linux and windows

1. Download samba

     yum  -y  install  samba

2. Modify the samba configuration. The default is under /etc/samba. It is recommended to back up smb.conf first.

     cd   /etc/samba

    cp smb.conf smb.conf.bak //Backup

    vim  smb.conf

    [global] //It comes after installation and does not need to be modified.

        workgroup = SAMBA                 

        security = user                       

       passdb backend = tdbsam

        printing = cups

        printcap name = cups

        load printers = yes

        cups options = raw

        [test] //Shared file name

        comment = Temporary file space //Description

        path = /data/test //Mount directory

        writable = yes //Permissions, that is, whether the user can write

        browseable = yes //Whether it can be browsed

        guest ok = yes

        valid users = root,test //user

3. Add users, user groups, and set permissions

   useradd test //Add user

   smbpasswd -a test //Set user password

   groupadd softadm //Add group

   usermod -G softadm test //Add user to group

   chgrp softadm /data/test/ //Change the group to which it belongs

   chmod 777 /data/ //Add directory permissions

   grep softadm /etc/group //View group

   testparm //Detect syntax errors

   service smb restart //Start samba

4. Windows access method: windows+R, enter the IP, that is, //192.168.0.x, enter the user name and password you set on linux, and then a folder will appear, which is the folder you just set in linux. The defined folder is the test folder. Put the Windows desktop file into test. At this time, the file also exists in the /data/test directory of Linux, as shown in the figure below

5. If windows prompts "You do not have access to \\192.168.0.x. Please contact the administrator to request access permissions" when accessing windows, you need to check the firewall and samba. If the firewall settings are confirmed, the samba settings are no problem, and samba has been Started, make sure there is no problem with the read and write permissions of the shared directory. It is possible that selinux has disabled samba .

   systemctl status firewalld //If the status is on, it needs to be closed

   service smb status //View samba status

   ll /data/ //View directory permissions

   getenforce //Check selinux status, if it returns Enforcing, you need to set it

    Setenforce 0 //Temporarily modify the selinux status. If permanent modification is required, modify it in /etc/selinux/config

6. If the following problems occur when accessing Linux files, solve them according to the methods:

 

Guess you like

Origin blog.csdn.net/qq_66349701/article/details/131032177