Installation and use of Samba for Linux and Windows shared folders (Ubuntu for example)

Source: Internet
Author: User

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
// 修改 /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!

Reprint Source: http://www.cnblogs.com/gzdaijie/p/5194033.html

Installation and use of Samba for Linux and Windows shared folders (Ubuntu for example)

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.