Ubuntu 20.04 share folders to windows through samba

Preface

  • There are two ways to share between ubuntu and windows. One is to share the directory of windows to ubuntu. For example, if you use a VM Ware virtual machine to share folders directly through the VMWare virtual machine, the directory on windows will be shared with ubuntu.

  • How to share directories in ubuntu to windows?

  • File directory sharing, who shares it between Ubuntu and Windows? Is there any difference?

Why Choose Linux Hosting to Share Files

  • The main difference between files or directories: In a certain directory on Windows: files or directories cannot have the same name, and are not case-sensitive.

  • For example, in the hello directory: Windows does not allow hello.txtfiles and Hello.txtfiles to exist at the same time, but Linux allows

  • For example, in the hello directory: Windows does not allow hellofolders and Hellofolders to exist at the same time, but Linux allows

  • For example, in the hello directory: Windows does not allow hellofiles and Hellofolders to exist at the same time, but Linux allows

  • Soft links are not supported on Windows, but are supported on Linux.

  • For these differences, it is recommended that ubuntu share files, so that ubuntu will not lose some files or soft links when going to Linux or windows.

ubuntu 20.04 open samba

  • Just install it directly with apt install under ubuntu

  • sudo apt install samba samba-common

configure samba

  • back up the original /etc/samba/smb.conf ,sudo cp /etc/samba/smb.conf /etc/samba/smb_bk.conf

  • edit /etc/samba/smb.conf ,sudo vim /etc/samba/smb.conf

  • Add shared directory information, currently I /home/zhangszshare it

[share]
        comment = share
        path = /home/zhangsz
        browseable = yes
        writable = yes
        read = yes
        directory mask = 0775
        create mask = 0775

Start the samba service

  • sudo service smbd restartOr sudo service smbd startstart the samba servicesmbd

  • Add a service to the system so that the system starts every timesudo systemctl enable smbd

  • Turn off the [ubuntu] firewall: sudo ufw statusyou can view the current firewall status

  • sudo systemctl disable ufw.servicedisable firewall

windows access shared directory

  • Check the IP of ubuntu, and then enter \\ubuntu_ip, for example \\192.168.149.129, you can see the shared directory

Insert image description here

Insert image description here

Solution to login without permission

  • The default ubuntu account cannot be logged in and requires samba to be added.

Insert image description here

  • Add a samba account and set a password.sudo smbpasswd -a zhangsz

Shared directories can be mapped to shared disks

Insert image description here

Insert image description here

Insert image description here

summary

  • The first sharing may encounter the problem that the smbd service fails to open. At this time, you can constantly adjust the shared directory information to confirm whether a familiar one is not supported.

  • Sharing for the first time may require login account information. The account information at this time is usually the login information on Ubuntu.

  • If you do not have permission to log in, it is recommended to set the account and password for samba login.

  • If you have logged in to Samba before, you can first clear the [Login Credentials] on Windows and log in again.

Guess you like

Origin blog.csdn.net/tcjy1000/article/details/132751822