Samba configuration process in Linux
1. What is Samba?
Samba is a set of software packages that allow Linux to support the SMB protocol. Samba is a set of software that allows Linux systems to Apply Microsoft network communication protocols. It enables the machines running Linux to share files with printers with the computers running Windows.
2. What are the main functions of Samba?
1. provides resources for other operating systems such as Windows Shared Linux, which looks similar to shared Windows resources, and allows Windows users to browse the network using their network peers.
2. SMB customer features: The smbclint program provided by Samba can be used to access Windows resources in a way similar to FTP in Linux.
3. Back up resources on a PC: using a shell script named smbtar, you can use tar to back up and restore shared files on a remote Windows server.
4. Provides a command line tool to support some management functions of NT.
3. What is the composition of Samba?
A samba server actually contains two server programs:
1. Smbd is the core of samba. It establishes dialog processes, verifies user identities, and provides access mechanisms to file systems and printers.
2. Nmbd is a service provided by the samba server.
4. What are the steps for installing and configuring the Samba server? (Using readhat as an example)
Step 1: Check whether your Linux system has installed Samba-related servers:
Run the command: # rpm-qa | grep samba
Command output:
Samba-common-3.6.9-164.el6.x86_64
Samba-winbind-3.6.9-164.el6.x86_64
Samba-3.6.9-164.el6.x86_64
Samba-client-3.6.9-164.el6.x86_64
Samba4-libs-4.0.0-58.el6.rc4.x86_64
Samba-winbind-clients-3.6.9-164.el6.x86_64
Where,
Samba --> This package contains the main daemon files (smbd and nmbd );
Samba-common --> provides main samba configuration files (smb. conf) and smb. conf syntax check programs (testparm;
Samba-client-When linux acts as the samba client, it provides a set of required tools and commands.
If not, it indicates that the system is not installed. Download and install it directly. After installation, run the preceding command again to check whether the installation process is detailed. There are many references, the Samba service is installed by default in most systems. If the Samba server is installed in the system, the configuration process is started.
Step 2: configure the Samba server:
The configuration is actually relatively simple, but there are a lot of articles on the Internet. The key is to follow the steps and find that it is not successful, which is quite frustrating. This article does not talk much about the configuration principles. It only describes the configuration steps (haha, the brute force configuration method is simple and practical). For details about the principles, see smb. conf (5) manual page.
1. Backup configuration file:
Cp/etc/samba/smb. conf/etc/samba/smb. conf. bak
2. Add the following code at the end of file smb. cof:
[Yding]
Comment = yding
Path =/home/yding
Writable = yes
Path =/home/yding is the user directory you want to share, which must be available in Linux.
3. Add a Samba user. Note that the user to be added must be an existing user in your Linux system. Use the following command to authorize the system to access Samba.
Smbpasswd-a yding
It will prompt you to enter the access password and follow the prompts to set the access password.
So far, the configuration of the Samba server has been completed.
Step 3: Configure iptables:
Run the command: service iptables stop
What is the embodiment of brute-force configuration?
Step 4: Configure selinux:
Run the setenforce 0 command and change selinux = enforcing in the file/etc/SELINUX/config to SELINUX = disabled.
So far, Samba configuration is complete.
5. Linux shared directory access in Windows:
Enter your Linux IP address in the Windows Address Bar, for example:
Enter \ 192.168.1.104 and press enter to view the shared directory icon.
Click the yding folder. the user name and password pop-up window is displayed. Enter the user name and password you set during configuration to view the shared file directory.
There should be no problem in performing the above steps. If you have any questions, please inform us in time to learn and make progress together.
6. Example of accessing a Windows shared directory in Linux:
1. Create a shared directory in windows:
Note that you must select the shared user object and set the sharing permission, which is used when the shared directory is mounted in Linux.
2. Mount the shared directory in Linux:
Mount-t cifs-o username = LSQ, password = liyang520 // 192. 168. *. */test/home/yding/test/
Usrname and password are windows user names and passwords, // 192.168../Test is the IP address of windows and the name of the shared folder./home/yding/test/is the path where we want to mount the shared directory in windows to linux. The result is as follows:
The files in the shared directory test of windows are as follows:
It can be seen that the two are synchronized. Add, modify, and delete directories on one side. This method can greatly improve the development efficiency.
VII. Appendix: FAQs
1. Output smb: unrecognized service when executing the Command service smb status.
A: When we run the command # rpm-qa | grep Samba to check whether the samba service is installed in Linux, the output is as follows:
Samba-common-3.6.9-164.el6.x86_64
Samba-winbind-3.6.9-164.el6.x86_64
Samba-client-3.6.9-164.el6.x86_64
Samba4-libs-4.0.0-58.el6.rc4.x86_64
Samba-winbind-clients-3.6.9-164.el6.x86_64
The samba-3.6.9-164.el6.x86_64 is missing, which is the main program of Samba and of course cannot identify the service without installation. Find the corresponding installation package in the Linux redhat installation package and run the following command:
Output:-r -- 108 root 5250316 Oct 23 2013 samba-3.6.9-164.el6.x86_64.rpm
......
Check and run the following command: # service smb status
Output: smbd is stopped
Start it: # service smb start
Check again: # service smb status
Final output: smbd (pid 6415) is running...
OK.
2. mount failure: Cause determination and solution for various errors
(1) The user/password is incorrect during mounting.
Error message: mount error (13): Permission denied
Refer to the mount. cifs (8) manual page (e.g. man mount. cifs)
View the corresponding/var/log/message record results:
Oct 12 16:20:01 localhost kernel: Status code returned 0xc000006d NT_STATUS_LOGON_FAILURE
Oct 12 16:20:01 localhost kernel: cifs vfs: Send error in SessSetup =-13
Oct 12 16:20:01 localhost kernel: cifs vfs: cifs_mount failed w/return code =-13
(2) No shared directory
Error message: Retrying with upper case share name
Mount error (6): No such device or address
Refer to the mount. cifs (8) manual page (e.g. man mount. cifs)
View the corresponding/var/log/message record results:
Oct 12 16:20:06 localhost kernel: cifs vfs: cifs_mount failed w/return code =-6
Oct 12 16:20:17 localhost kernel: cifs vfs: cifs_mount failed w/return code =-6
Oct 12 16:20:17 localhost kernel: cifs vfs: cifs_mount failed w/return code =-6