Ubuntu Samba Server Configuration

Source: Internet
Author: User
Tags egrep

Ubuntu Samba Server Configuration

I recently made open source software. Sometimes a package involves several operating systems, including windows and Linux. it is not convenient to transfer packets between these two operating systems. scp or ssh cannot be used for operations. For convenience, A samba server is built on ubuntu to facilitate file sharing between windows and linux.

1. Install the samba Software Package

brandon@ubuntu:~$ sudo apt-get install samba
brandon@ubuntu:~$ sudo apt-get install smbfs
 
brandon@ubuntu:~$ smbd --versionVersion 4.1.6-Ubuntu
To install it through a graphical interface, you can also install the software package: python-glade2, system-config-samba. The python-glade2 can be used to call Python libraries in the creation GUI, system-config-samba, and is also a GUI-based management package for samba. 

 

2. Create a directory to be shared and modify the permission

 

brandon@ubuntu:~$ mkdir -p shareWindowsbrandon@ubuntu:~$ sudo chmod 777 shareWindows/

 

Brandon @ ubuntu :~ $ Ls-l | grep restart windowsdrwxrwxrwx 2 brandon 4096 20:19 windows

3. Back up the original samba configuration file and modify the samba configuration file.

 

brandon@ubuntu:~$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup

 

brandon@ubuntu:~$ sudo gedit /etc/samba/smb.conf

 

Because the smb. conf file is read-only, it is recommended that you do not forcibly modify the permission and use vim to modify it. You can directly use gedit to edit the text.

Modify the following fields:

# Change this to the workgroup/NT-domain name your Samba server will part
Workgroup = VMWARE
Displays charset = UTF-8
Unix charset = UTF-8
 

[Windows]
Comment = Ubuntu File Server Share
Path =/home/brandon/others windows
Available = yes
Browseable = yes
Guest OK = yes
Read only = no
Public = yes
Writable = yes
Create mask = 0755
Directory mask = 0700
Force user = nobody
Force group = nogroup

 

Brandon @ ubuntu :~ $ Sudo chown nobody: nogroup/home/brandon/customized Windows/brandon @ ubuntu :~ $ Ls-l | grep restart windowsdrwxrwxrwx 2 nobody nogroup 4096 April 20 22:59 restart Windows

 

 

If you want to enter the workstation name during configuration, go to the windows machine to query the workstation name:

Run the following command in cmd: net config workstation.


It is also possible not to join the same workgroup. Force user = nobody force group = nogroup has the same effect as command modification. select one of them.

Restart the samba service:

 

brandon@ubuntu:~$ sudo service smbd restart

 

4. Access this folder on a windows machine

Query IP Address:

 

brandon@ubuntu:~$ ifconfig
Then, you can access the ghost windows folder on samba server through an ip address on a windows machine: Enter the corresponding ip address here.

The created Windows folder is displayed:

5. Verify file read/write:

1) Create an empty folder on the linux machine and view it on the windows machine.

 

Brandon @ ubuntu :~ $ Cd running Windows/brandon @ ubuntu :~ /Uninstall Windows $ touch new.txt brandon @ ubuntu :~ /Login windows $ ls-ltotal 0-rw-rw-r -- 1 brandon 0 April 20 23:37 new.txt
Check the time on a windows machine because the time of the two systems is not set in a unified manner.

 



 

22.16.create a test.txt file in the Windows machine and write the file: This is a test file. view it on the ubuntu machine.

View on ubuntu:

 

Brandon @ ubuntu :~ /Login windows $ ls-ltotal 4-rw-rw-r -- 1 brandon 0 April 20 23:37 new.txt-rwxr -- r -- 1 nobody nogroup 22 April 20 23:52 test.txt brandon @ ubuntu :~ /Login windows $ cat test.txt This is a test file. brandon @ ubuntu :~ /Configure windows $
6. You can also create users and groups with administrative permissions and set the access password. This will prompt you to enter the password when accessing from a windows machine.

 

 

brandon@ubuntu:~$ sudo addgroup smbgrpAdding group `smbgrp' (GID 1001) ...Done.
Brandon @ ubuntu :~ $ Ls-l | egrep? Windowsdrwxrwxr-x 2 brandon smbgrp 4096 April 21 00:20 secureWindowsdrwxrwxrwx 2 nobody nogroup 4096 April 20 23:47 windows
Brandon @ ubuntu :~ $ Sudo chmod 0770/home/brandon/secureWindows/brandon @ ubuntu :~ $ Ls-l | egrep? Windowsdrwxrwx --- 2 brandon smbgrp 4096 April 21 00:20 secureWindowsdrwxrwxrwx 2 nobody nogroup 4096 April 20 23:47 windows

 

brandon@ubuntu:~$ sudo adduser brandon smbgrpAdding user `brandon' to group `smbgrp' ...Adding user brandon to group smbgrpDone.
brandon@ubuntu:~$ sudo smbpasswd -a brandonNew SMB password:Retype new SMB password:Added user brandon.brandon@ubuntu:~$ 
Modify the/etc/samba/smb. conf file and add a new samba shared file field.

[SecureWindows]

Comment = Ubuntu File Server Share
Path =/home/brandon/secureWindows
Available = yes
Valid users = @ smbgrp
Browseable = yes
Guest OK = no
Writable = yes

Restart the samba Service

 

brandon@ubuntu:~$ sudo service smbd restartsmbd stop/waitingsmbd start/running, process 13656

 

In this case, you are prompted to enter the password when you ask this folder on a windows machine:

Verification:

Enter the password to create a new file.

View

 

brandon@ubuntu:~/secureWindows$ ls brandon@ubuntu:~/secureWindows$ lsfileFromWin.txtbrandon@ubuntu:~/secureWindows$ cat fileFromWin.txt This is test at windows machine.brandon@ubuntu:~/secureWindows$ 

 

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.