Samba file sharing service (sharing scripts make your work easier)

Source: Internet
Author: User

Samba is a free software that implements the SMB protocol on Linux and UNIX systems. It consists of servers and client programs. Experimental environment: according to the company's informatization construction requirements, a file server needs to be built in the LAN to facilitate centralized data management and backup. Considering the file security, operational efficiency, and stability, select

To build a file sharing server!

Experiment and explanation: window anonymous access to linux services

First mount the CD to install Samba and then configure the IP address

Mount: block device/dev/sr0 is write-protected, mounting read-only‍


650) this. width = 650; "title =" Your png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHJ920-0.png" width = "559" height = "353"/>

650) this. width = 650; "title =" 21.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHK019-1.png"/>


650) this. width = 650; "title =" 22.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHGB2-2.png"/>


650) this. width = 650; "title =" 23.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHHc2-3.png"/>

Install software

Create a test folder

Filter the configuration file and edit the configuration file: in/etc/samba/smb. conf

Check whether the port numbers smbd occupy port 139 and port 445.

Netstat-tlnp | grep smb
Tcp 0 0 0.0.0.0: 139 0.0.0.0: * LISTEN 13139/smbd
Tcp 0 0 0.0.0.0: 445 0.0.0.0: * LISTEN 13139/smbd

Back up the smb. conf file

The configuration files of the Samba server are located in the/etc/samba directory, and the main configuration file of the server is smb. conf; user configuration files such as smbpasswd, smbusers, and lmhosts; and secrets. tdb. This file is automatically generated by the Samba server startup.

Mv/etc/samba/smb. conf/etc/samba/smb. conf. bak

Ls/etc/samba
Lmhosts passdb. tdb secrets. tdb smb. conf. bak smbpasswd smbusers

4. Set the samba server to enable Anonymous read/write

[STEP 1] configure the smb. conf file

Touch smb. conf

Vim smb. conf

/* Global configuration */

[Global]

Workgroup = root // similar to the workgroup name displayed in Windows

Netbios name = mabin-samba // name of the computer parsed by netbios

Server string = samba testserver // server description

Security = share // security is the login and authentication method. It is set to share for anonymous access. If it is a user authentication method, the user name and password are required.

[Root] // name of the shared directory displayed in Windows

Path =/var/samba // path of the shared directory

Writeable = yes // whether it is writable

Browseable = yes // whether to browse

Guest OK = yes // set anonymous users to log on as guest


650) this. width = 650; "title =" 26.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHH247-4.png"/>

Firewall must be disabled

650) this. width = 650; "title =" 27.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHM202-5.png"/>

Test whether access is allowed

650) this. width = 650; "title =" 30.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHJ410-6.png"/>

650) this. width = 650; "title =" 31.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHM2Q-7.png"/>

Text is the folder created on linux

2: Access verified by the user. We use Samba to achieve the simplest anonymous sharing, but in most cases, we want to be able to authenticate users who access Shared Files and assign relevant permissions.

Make an experiment:

The company has three departments: finance, personnel, and technology.
Requirements:
1. Each department has a public folder on the file server. This folder can only be accessed by employees of the corresponding department and written to it, but cannot be deleted, it cannot be accessed by employees of other departments.
2. Each employee has an independent folder on the file server. This folder can only be accessed by the employee himself, and no one else has access permissions.

The address may be different. I did one at school and the other at home. I will not change the address for convenience!


[Root @ jack/] # mkdir/caiwu/share create several test folders
[Root @ jack/] # mkdir/renshi/share
[Root @ jack/] # mkdir/jishu/share


[Root @ jack/] # useradd caiwu and then create several users
Root @ jack/] # useradd renshi
[Root @ jack/] # useradd jishu

650) this. width = 650; "title =" 39.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHJY8-8.png"/>


[Root @ jack/] # gpasswd-a tom caiwu add users to the group
Dding user tom to group caiwu
[Root @ jack/] # gpasswd-a jack renshi
Adding user jack to group renshi
[Root @ jack/] # gpasswd-a jone jishu
Adding user jone to group jishu

[Root @ jack/] # echo "This is caiwu bu">/caiwu/share/caiwu.txt Test File
Oot @ jack/] # ls-l/caiwu/share/


[Root @ jack/] # chown root: caiwu/share/modify the owner and group of the Directory
Root @ jack/] # ls-l/caiwu/

Drwxrwx ---. 2 root caiwu 4096 20:51 share

650) this. width = 650; "title =" image 1.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHLT7-9.png "/>

Then access

650) this. width = 650; "title =" image 2.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHL528-10.png "/>


You can access your group.

650) this. width = 650; "title =" image 3.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHLV1-11.png "/>

This prompt will be displayed when you view other folders.

650) this. width = 650; "title =" image 4.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHL494-12.png "/>

650) this. width = 650; "title =" image 5.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHM3D-13.png "/>

Clear remote list information

650) this. width = 650; "title =" image 6.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHM914-14.png "/>

650) this. width = 650; "title =" image 7.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHL014-15.png "/>

Create a test file

650) this. width = 650; "title =" image 8.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHG617-16.png "/>

650) this. width = 650; "title =" image 9.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHL940-17.png "/>

650) this. width = 650; "title =" image 10.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHLQ5-18.png "/>

Files cannot be created, but files can be written!

650) this. width = 650; "title =" image 11.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHMW4-19.png "/>

650) this. width = 650; "title =" image 12.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHK427-20.png "/>


Every user has a home directory.

650) this. width = 650; "title =" image 13.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHK433-21.png "/>

650) this. width = 650; "title =" image 14.png "src =" http://img1.51cto.com/attachment/201306/151807212.png "/>

650) this. width = 650; "title =" image 15.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHGa8-23.png "/>

[Root @ jack/] # echo "my name is jone">/home/jone/jone.txt add this word to Windows in linux.


650) this. width = 650; "title =" image 16.png "src =" http://www.bkjia.com/uploads/allimg/131227/1PHGW3-24.png "/>


3: Use Windows to share linux Access Services


First, I shared my technical information on the real machine.

650) this. width = 650; "title =" 34.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHLM1-25.png"/>

650) this. width = 650; "title =" 35.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHH648-26.png"/>

650) this. width = 650; "title =" 36.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHH0K-27.png"/>

Then mount it!

650) this. width = 650; "title =" 37.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHJ014-28.png"/>

If someone cannot mount the cifs package, the cifs package may not be installed. If you do not know it, You can directly guess that it is often used for future work. For example, if a software package does not have a name, however, you can use the method of guessing to filter out the name on the disc. For example, you can guess the network on the network. Here, you can guess the cifs and install it directly.

650) this. width = 650; "title =" 38.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHK950-29.png"/>

It is very convenient to directly access your window file below!


To facilitate my own script:

@ ECHO Off
Color 1F
ECHO.
ECHO was too busy when there were too many attempts to handle these issues.
ECHO too many attempts made too many★= ☆=★= LAN sharing =★= ☆=★When there are too many other users
ECHO was too busy when there were too many attempts to handle these issues.
ECHO program this program can share the LAN file technology empty production program
ECHO too many
ECHO too many threads =★= ☆=★======================================★= ☆=★= Too many threads
Echo.
Echo -----------------------------------------------------------
Set/p ip = enter the ip address of the local connection:
Set/p sh = Share Name:
Set/p us = enter the User Name:
Set/p pa = enter the password:
Echo -----------------------------------------------------------
Net use \ % ip % \ % sh % "% pa %"/user: "% us %"
Net share
Echo -----------------------------------------------------------
Net use Z: \ % ip % \ % sh %
Echo -----------------------------------------------------------
Net use/d *
Echo -----------------------------------------------------------
Echo.
Echo press enter to exit
Echo.
Echo -----------------------------------------------------------
Set/p test =
Exit

If you have any questions, please contact me to directly create a shared script. It is especially convenient to directly double-click it.


650) this. width = 650; "title =" 40.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHJ005-30.png"/>

650) this. width = 650; "title =" 41.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHL646-31.png"/>

650) this. width = 650; "title =" 42.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHI195-32.png"/>

650) this. width = 650; "title =" 43.png" src = "http://www.bkjia.com/uploads/allimg/131227/1PHL0X-33.png"/>


Dear friends, is it very convenient? It is easy to maintain and double-click your computer to directly open a network disk, which is a file sharing folder! It makes your work much easier and is often used in the company for FTP and file sharing. But there are a lot of people who won't access it, so sometimes the Administrator is under a lot of pressure. If everyone asks you once, you will be able to go back and forth to increase the workload a little script!


This article is from the "technical control" blog, please be sure to keep this source http://chenhao6.blog.51cto.com/6228054/1218028

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.