Share multiple folders between ubuntu Linux and Windows (using Samba)
Preface
When working on embedded Linux projects, the two systems often use common resources, so we plan to create a shared folder to facilitate mutual transfer between the two platforms and cross-platform compilation of source code. For the process of creating a single folder, you can refer to this blog post
In case the above link fails, the following will also briefly describe how to share a folder
Share a single folder
(1) Install Samba under Ubuntu
First use the command sudo apt-get install samba
on the Ubuntu command line to install samba.
Mine has been installed in advance:
(2) Configure the smb.conf file
After installing samba, you can configure smb.conf: Use the command vi /etc/samba/smb.conf
to open the smb.conf file, and write the content in the red box below the last line:
Note: 1. This [code]
is the name of the shared folder that will appear in Windows
2. This path=/home/ubuntu/work
refers to the path of the folder you want to share. I want to share a folder named work
. This folder It is best to have higher permissions. I gave it read, write and executable permissions
After the modification is completed, save and exit. If it prompts that it is a read-only file:
Then Usesudo chmod 666 /etc/samba/smb.conf
to change it to read and write permissions, and then add the content in the red box above:
(3) Restart the samba service
After modifying this file, save and exit, use sudo pkill smbd
to close the service, and then use sudo smbd
to open the service, which is equivalent to restarting it and letting it start. function, so that you can return to the Windows connection shared directory
(4) Obtain Ubuntu’s IP address
Use the ifconfig
command directly to get the following IP address in the red box:
Windows will use it to access the shared folder
(5) Windows connection shared directory
Open the command run box directly in Windows using the Win + R
key and enter \\192.168.204.131
(two backslashes and the IP address obtained above) a>
Then press 确定
to see and operate the shared folder.
Share multiple folders
There is not much difference between sharing multiple folders and a single one. The key is to add an extra piece of content to multiple folders in the smb.conf
directory. Here we take sharing two folders as an example. In this:
[code]
path=/home/ubuntu/work/v53
writable=yes
browseable=yes
guest ok = yes
Add a piece of content in the same format after:
[csdn]
path=/home/ubuntu/work/project_space
writable=yes
browseable=yes
guest ok = yes
How many folders do you want to share? Just write a few of the contents in these formats. I will share them here. code
and csdn
two folders, you only need to write these two paragraphs:
three or more By analogy
Note: After saving and exiting the file, use sudo pkill smbd
and sudo smbd
Command to restart the service, so that you can see these two folders when you reopen the Windows connection shared directory
postscript
There are many methods online, but I only know this one at the moment, so I just recorded it. If there are any omissions, please let me know.