Install Samba in Linux to share files with Windows

Source: Internet
Author: User

Samba is suitable for Intranet file sharing. This tutorial is applicable to Ubuntu/Fedora.

1. Check whether the installation is complete.

# Rpm-Q samba

Package Samba is not installed

2. Use the yum query package

# Yum list Samba (query the software package to obtain the installable software package: Samba. i686)

3. Use yum for installation (Select Yes for installation)

# Yum install Samba. i686

Start

Service iptables stop

Service SMB start

Service nmb start

The smbd process processes SMB request packets (port 139) and is responsible for verification and file sharing (important ). Nmdb (port 137 138)

Systemctl

Configuration:

Query which software packages are installed.

# Rpm-Qa | grep samba

Find the configuration file and go to the common software package.

# Rpm-q | samba-common-4.0.3.2 | grep smb. conf

Found:/etc/samba/smb. conf


Backup:

# Cp Samba. conf Samba. conf. Bak

[Global] global

Workgroup = Specify a workgroup or domain

Server String = Description

Security = Specified security mode (share has no permission verification, and user has Server Authentication (default ))

Hosts allow = restrict host access (which hosts can access and which users)

Use ip cidr blocks such as 162.1.2.

Log File = Specify the storage location of log files

Specific Configuration:

Annotations starting with; are valid configurations, that is, remove the semicolon and write and modify it.

1. Configure hosts

My configuration allows 10.5.82.

Hosts allow = 10.5.82.

2. You can customize security configurations.

Home: The Home Directory of the shared user.

Comment = Description

Browseable = No (directory with no access permission, invisible)

Writable = Yes


3. Add users first:

Adduser sambatest

The added samda user must be a system user.

Assdb backend = tdbsam passdb backend is the user background. Three backends are available: smbpasswd, tdbsam, and ldapsam.
Sam is the security account manager.
1. smbpasswd: This method uses the SMB tool smbpasswd to set a samba password for system users (real users or virtual users). The client uses this password to access Samba resources. In/etc/samba, smbpasswd sometimes needs to be created manually.
2. tdbsam: create a user database using a database file. The database file is called passdb. TDB and is in/etc/samba. Passdb. TDB user database can use smbpasswd-a to create a samba user. The Samba user to be created must first be a system user. You can also use pdbedit to create a samba account. There are many pdbedit parameters to list:
Pdbedit-a username: Create a samba account.
Pdbedit-x Username: Delete the samba account.
Pdbedit-L: List Samba users and read the passdb. TDB database files.
Pdbedit-LV: list detailed information about Samba users.
Pdbedit-C "[d]"-u Username: suspend this Samba user account.
Pdbedit-c "[]"-u Username: Restore the samba user account.
3. ldapsam: authenticates users based on LDAP account management. First, you must establish the LDAP service and set "passdb backend = ldapsam: LDAP: // LDAP server"


Access through windows:

Enter \ Linux address during running

\ 192.168.175.130

In the displayed dialog box, enter the user name and password.

If you cannot access the service after the logon is successful:

# Setsebool-P samba_enable_home_dirs on

[global]workgroup = MYGROUPserver string = Samba Server Version %v;netbios name = MYSERVER;interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24hosts allow = 127. 192.168.12. 192.168.13. 10.5.82. 192.168. 10.5.# logs split per machinelog file = /var/log/samba/log.%m# max 50KB per log file, then rotatemax log size = 50security = user;passdb backend = tdbsam;security = domain;passdb backend = tdbsam;realm = MY_REALM;password server = <NT-Server-Name>;security = user;passdb backend = tdbsam;domain master = yes ;domain logons = yes# the login script name depends on the machine name;logon script = %m.bat# the login script name depends on the unix user used;logon script = %u.bat;logon path = \\%L\Profiles\%u# disables profiles support by specifing an empty path;logon path =          ;add user script = /usr/sbin/useradd "%u" -n -g users;add group script = /usr/sbin/groupadd "%g";add machine script = /usr/sbin/useradd -n -c "Workstation (%u)" -M -d /nohome -s /bin/false "%u";delete user script = /usr/sbin/userdel "%u";delete user from group script = /usr/sbin/userdel "%u" "%g";delete group script = /usr/sbin/groupdel "%g";local master = no;os level = 33;preferred master = yes;wins support = yes;wins server = w.x.y.z;wins proxy = yes;dns proxy = yesload printers = yescups options = raw;printcap name = /etc/printcap#obtain list of printers automatically on SystemV;printcap name = lpstat;printing = cups;map archive = no;map hidden = no;map read only = no;map system = no;store dos attributes = yes[homes]comment = Home Directoriesbrowseable = nowritable = yes;valid users = %S;valid users = MYDOMAIN\%S[printers]comment = All Printerspath = /var/spool/sambabrowseable = noguest ok = yeswritable = yesprintable = yes;[netlogon];comment = Network Logon Service;path = /var/lib/samba/netlogon;guest ok = yes;writable = no;share modes = no;[Profiles];path = /var/lib/samba/profiles;browseable = no;guest ok = yes;[public];comment = Public Stuff;path = /home/samba;public = yes;writable = yes;printable = no;write list = +staff[myshare]comment = gaotong's filespath = /home/sharepublic = yeswirtable = yesprintable = no

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.