Ubantu Sharing with Windows resources

Source: Internet
Author: User

@gzdaijie
This article is the author original, reproduced please indicate the source: http://www.cnblogs.com/gzdaijie/p/5194033.html

Table of Contents 1. Write in front
2. Installation method
2.1 Installing Samba
2.2 Creating a shared directory
2.3 Modifying the Samba configuration file
2.4 Setting the login password
2.5 Starting the Samba server
2.6 Test for shared success
3. Testing on Windows
3.1 Open the Windows File Manager and enter the \\IP address or host name \share
3.2 Enjoy the convenience of samba
1. Write in front

What do you do when you install a Linux virtual machine on Windows and you want to access a folder in Linux and copy the files from the virtual machine to the Windows host? What if this Linux host is not a virtual machine, but a remote host?
Is there a way to open a folder in a Linux virtual machine as if it were local, and enter the path? You might think of FTP, this article describes an easier way to--samba.
Next, we'll show you how to install Samba on Linux (take Ubuntu14.04 as an example).

2. Installation method 2.1 Installing Samba
sudo apt-get install samba
2.2 Creating a shared directory
// 创建的目录即之后能够在Windows主机上直接访问的目录。// 例如:在用户gzd的主目录下新建share文件夹为共享目录mkdir /home/gzd/smbshare// 由于Windows下的文件夹需可读可写可执行,需更改权限为777sudo chmod 777 /home/gzd/smbshare
2.3 Modifying the Samba configuration file

I remember to add Security=user cat back

// 修改 /etc/samba/smb.confsudo vim /etc/samba/smb.conf// 在smb.conf文件最后加上以下内容

[Share]
Path =/home/gzd/smbshare
Public = yes
writable = yes
Valid users = Gzd
Create mask = 0644
Force Create mode = 0644
Directory mask = 0755
force directory mode = 0755
Available = yes

A few explanations about smb.conf:

(1) [share] indicates the alias of the shared folder, which will be used directly after the alias

(2) force create mode force directory mode the setting is due to the different default permissions for files and folders under Windows and Linux, the new files under Windows are executable and must be forced to set their file permissions.

(3) Valid users is set to your current Linux username, for example my is Gzd, because the first time you open a shared folder, you need to verify permissions.

2.4 Setting the login password
// 新建/etc/samba/smbpasswd文件sudo touch /etc/samba/smbpasswd// 根据2.3设置的valid users,设置用户密码// gzdaijie 替换为你在2.3中设置的用户名sudo smbpasswd -a gzd//输入两次密码后,会提示 Added user gzd. 表示设置成功// 若用户名非当前登录系统的用户名,可能会提示Failed
2.5 Starting the Samba server
sudo /etc/init.d/samba restart
2.6 Test for shared success
sudo apt-get install smbclient smbclient -L //localhost/share//还记得吗?share为2.3中设置的共享文件夹的别名//如果共享成功,将要求输入之前设置的密码
3. Test 3.1 on Windows open the Windows File Manager and enter the \\IP address or host name \share
    • The IP address of Linux can be viewed through ifconfig
    • Select remember credentials and do not need to log in next time you enter an address
    • It may take a few seconds to open the first time, just be patient.

3.2 Enjoy the convenience of samba
    • Create a file under Windows, and look under Linux!
    • Create a file under Linux's shared directory, and look under windows!

Set up sharing under Ubuntu
1. Installing Samba
sudo apt-get install samba Smbfs
2. Set Samba password
sudo touch/etc/samba/smbpasswd
sudo smbpasswd-a yourname #yourname represents your user name
Then follow the prompts to enter the password
3. Select the folder you want to share, right click on "Properties", then click "Share";
4. Enter the share name, usually with the same name as the folder, if the following third step error please change the name to try;
5. Select the first option "Share this fold", the second one can also be selected, the third one does not recommend the election;

Your map address is "\\ubuntu-IP\sharename", Ubuntu-ip is the IP address of your Ubuntu host, sharename is the share name you entered in the 3rd step above.
then follow the prompts to enter the user name and shared password.
If you are on a Linux system, you can access the share you created with the Mount command:
sudo mount//ubuntu-ip/sharename share_temp/-o Username=yourname,password =yourpasswd,fmask=777,dmask=777
Share_temp is one of your local folders, which is to temporarily place the share in this folder.  

How common users under Ubuntu create shares
After a normal user logs in, the following method is used to create the shared folder, the error is indicated:
' Net Usershare ' returned error 255:net Usershare:cannot open Usershare directory/var/lib/samba/usershares. Error Permission denied
Permission to create a usershare. Ask your administrator to grant you permissions to create a share. Just add the user to the Sambashare user group at this point, as follows:
sudo adduser yourname sambashare
After logout, you can set up the shared folder again.
But you won't be able to apply your share at this point, you'll need to set up your Samba password first.
sudo smbpasswd–a yourname
Then follow the prompts to set up your Samba password.
Description
Common user settings Sharing is a problem that has plagued many people. For this question for a long time not answer, online saying a lot, finally found that as long as the corresponding user to join the Sambashare user group on it.
In fact, from the error message can also get the corresponding hint/var/lib/samba/usershares, and then view the properties:
ls/var/lib/samba/-L
Drwxrwx--t 2 root sambashare 4096 2010-12-30 10:57 usershares
The first column represents the permission, the third column represents the owner, and the fourth column represents the user group. Since the prompt permission is not enough, there is reason to suspect that it is not the appropriate group.
Generally encountered in this situation to modify the corresponding file (folder) user groups or permissions is not wise, and it is likely to lead to new problems, so you must find another method of finding the root cause of the problem.

Ubantu Sharing with Windows resources

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.