In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the steps of installing and configuring Samba server in Linux system". In the daily operation, I believe that many people have doubts about the steps of installing and configuring Samba server in Linux system. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "steps to install and configure Samba server in Linux system". Next, please follow the editor to study!
First, obtain the source code package and decompress it
The latest samba source code package can be downloaded from samba's official website. Let's take the samba-3.5.9.tar.gz source code package as an example to parse. In this example, we put the source code package in the directory / home/samba, and then execute the following command to extract it.
The code is as follows:
# tar-xzvf samba-3.5.9.tar.gz
2. Configure configure
After unzipping the source code package, enter the directory
The code is as follows:
# cd / home/samba/samba-3.5.9/source3
Then execute the following command to configure.
The code is as follows:
#. / configure
Perhaps at the beginning, there is no configure file in this directory, so you can execute the following command first
The code is as follows:
#. / autogen-sh
At this point, the system is required to install autoconf, automake and other tools.
Before running the above configuration command, we can use the command
The code is as follows:
#. / configure-help
To see some options for the configuration command.
Generate and install make & & make install
After the environment configuration command. / configure is successfully executed, you can run the command
The code is as follows:
# make
To generate a binary executable file, which may take two to three minutes. After successfully generating the executable file, you can use the following command
The code is as follows:
# make install
To install. The default installation path of the system is / usr/local/samba
Configure the dynamic link library path
After the installation is complete, we need to configure the dynamic link library path, because smbd and nmbd running samba need to go to the dynamic link library file under the directory / usr/local/samba/lib. But this directory is not the system's default dynamic link library file search path, so we need to add this directory to the file ld.so.conf. Execute the following command
The code is as follows:
# vi / etc/ld.so.conf
Open the ld.so.conf file and add the following line to the file.
The code is as follows:
/ usr/local/samba/lib
And then execute the command.
The code is as follows:
# ldconfig
To update the dynamic link library buffer.
5. Samba configuration file smb.conf
The configuration file smb.conf is required for samba to run. The smb.conf configuration file is the most important configuration file for samba, which defines the security mechanism of samba, the directories and parameters for file sharing and print sharing, and other system configuration functions.
The default path of the configuration file smb.conf is / usr/local/samba/lib/smb.conf. When running the smbd process, we can use the-s option to execute a specific smb.conf file (see the next section for details). Generally, the-s option is not recommended because its configuration tools, such as smbclient, testparm, and so on, default to read / usr/local/samba/lib/smb.conf files. Let's illustrate it with a simple configuration file with the path / etc/samba/smb.conf.
The code is as follows:
[global]
Workgroup = MYGROUP
Server string = Samba Server% v
Security = user
Log file = / var/log/samba/%m.log
Passdb backend = smbpasswd
Smbpasswd file = / etc/samba/smbpasswd
[root]
Path = /
Valid users = root
Writeable = yes
[public]
Path = / data
Guest ok = yes
Read only = yes
The above configuration file defines two file sharing services, root and public. We will not discuss the details of the above configuration file in detail here. The main point here is that the default backend for verifying a user's password before version 3.0.23 of samba is smbpasswd, while the default backend after version 3.0.23 is tdbsam. We can select a specific backend through the parameter passdb backend. When / usr/local/samba/private/smbpasswd the password file read by default when using smbpasswd, we can specify a specific password file through smbpasswd file.
After configuring the smb.conf file, we can run the testparm (directory / usr/local/samba/lib) command to check the syntax of the smb.conf file, which will detect problems such as which parameter names are not recognized.
6. Start samba
Samba has two main processes, smbd and nmbd. The smbd process provides file and print services, while nmbd provides NetBIOS name services and browsing support to help SMB customers locate servers and handle all UDP-based protocols.
After configuring the smb.conf file, before starting the service process running samba. We need to do some preparatory work first. Run the smbpasswd command (under directory / usr/local/samba/bin)
The code is as follows:
#. / smbpasswd-a root
Add root user and password information to the / etc/samba/smbpasswd file specified in the smb.conf file. For a detailed introduction to the smbpasswd file, see the relevant documentation.
Then run the command
The code is as follows:
# service iptables stop
Turn off the firewall because it may prevent users from accessing the machine. Here are the service processes smbd and nmbd that run samba
The code is as follows:
# / usr/local/samba/sbin/smbd-D-s / etc/samba/smb.conf
# / usr/local/samba/sbin/nmbd-D-s / etc/samba/smb.conf
The-D option above specifies that smbd and nmbd are started as daemons, and a specific configuration file / etc/samba/smb.conf is specified through the-s option. The advantage of starting smbd and nmbd as a daemon is that it is fast to respond, but if you want to close it, you have to kill it. Of course, we can perform these operations through scripts, so scripts are not provided here.
7. Smbclient carries on the test inspection
After starting samba, we can test it locally using smbclient (under directory / usr/local/samba/bin). The following command
The code is as follows:
# cd / usr/local/samba/bin
#. / smbclient-L / / 127.0.0.1
You can list the services provided by this samba server. The result of this example is as follows:
The code is as follows:
[root@localhost bin] #. / smbclient-L / / 127.0.0.1
Enter root's password:
Domain= [MYGROUP] OS= [Unix] Server= [Samba 3.5.9]
Sharename Type Comment
IPC$ IPC IPC Service (Samba Server 3.5.9)
Public Disk
Root Disk
Domain= [MYGROUP] OS= [Unix] Server= [Samba 3.5.9]
Server Comment
--
LOCALHOST Samba Server 3.5.9
Workgroup Master
--
MYGROUP LOCALHOST
Of course, you can also access the services provided by the samba server through smbclient. The command format is as follows:
The code is as follows:
#. / smbclient "/ serverAdderss/aservice"-U username
Where serverAddress is the IP address of the samba server to be accessed, aservice specifies a service name provided on the samba server, and the option-U username specifies which user name to use to access the samba server. For example
The code is as follows:
[root@localhost bin] #. / smbclient "/ / 127.0.0.1/root"-U root
Enter root's password:; # enter the password of the samba user root here
Domain= [MYGROUP] OS= [Unix] Server= [Samba 3.5.9]
Smb:\ >; # access succeeded. Enter relevant commands to operate.
The above smb:\ > indicates that the access is successful, so we can enter some commands to operate on the samba server, such as ls, mkdir, and so on. The Q or quit command exits and disconnects.
Access the samba server from the Windows client
In the Windows client, you can access the root service provided on the samba server 192.168.1.34 by creating a new network neighbor in the network neighbor, or by typing\\ 192.168.1.34\ root in [start]-[run].
IX. Description of important options
Global options:
The global option is used in the option definition of [global], which describes some basic properties of the samba server. Some of its options can be overridden by option definitions in others.
Workgroup = MYGROUP
Define the workgroup or domain where the samba server is located (if you set security = domain).
Server string = Samba server
Set the description of the samba server, which can be seen in the comments when accessed through a network neighbor.
Hosts allow = host (subnet)
Set the host IP or network that is allowed to access the samba server. The value of this option is a list type, separated by spaces or commas between different items, such as hosts allow = 192.168.3.0, 192.168.1.1. This option setting allows host 192.168.1.1 and all hosts within subnet 192.168.3.0 to access the samba server.
Hosts deny = host (subnet)
Sets the host IP or network that is not allowed to access the samba server in the same format as hosts allow.
Guest account = guest
The visitor account is set, and when the visitor accesses the sharing service of guest ok = yes, the samba server will set up the client to access the share with the visitor account.
Log file = MYLOGFILE
Sets the location of the record file.
Max log size = size
Sets the size of the record file in KB. If set to 0, there is no size limit.
Security =
Sets the security level of the samba server, which has four security levels: share, user, server, and domain. The default is user. For more information about these four levels of security, please see the relevant documentation.
Password server = ServerIP
The user account authentication server IP is set, which is valid when setting security = server.
Encrypt passwords = yes | no
Sets whether the password is encrypted. If the password is not encrypted, the client and server pass the plaintext password during the authentication session. However, some Windows systems do not support plaintext password transmission by default.
Passdb backend = smbpasswd | tdbsam | ldapsam
Set the backend where the samba server accesses and stores samba user accounts, in samba-3.0. The default value before 23 is smbpasswd, and the default value after is tdbsam.
Smb passwd file =
Set the user account file for samba. For samba installed in source code, the default value is / user/local/samba/private/smbpasswd; before samba-3.0.23 and / usr/local/samba/private/passwd.tdb after samba-3.0.23.
Include = smbconfFile
The include option allows you to include other configuration files, which, along with some samba-defined variables, allow you to set configurations related to different machines.
Local master = yes | no
Sets whether the samba server attempts to become the local master browser. The default value is yes. If set to no, the samba server can never become the local owner browser, and setting it to yes does not mean that it can become the local owner browser, but only allows it to participate in the election of the local owner browser.
Os level = N
N is an integer that sets the weight of the samba server when participating in the local master browser election. The higher the value, the greater the weight. When os level = 0, the server loses the opportunity to elect.
Domain master = yes | no
Set the samba server to be a domain browser. The domain browser gets the browse list from each local master browser and passes the browse list of the entire domain to each local master browser.
Preferred master = yes | no
Set whether the samba server is the primary primary browser in the workgroup, and if set to yes, a browsing selection will be forced when nmbd starts.
Local options:
The local option is the parameter in each except global. It defines the properties of the shared service.
Comment =
Set the description of the shared service.
Path =
Set the path to the shared service, which can be set in combination with samba predefined variables.
Hosts allow = host (subnet)
Hosts deny = host (subnet)
It has the same meaning as global hosts allow and hosts deny, which overrides global settings.
Read only = yes | no
Sets whether the shared service is read-only, which has a synonymous option writeable.
User = user (@ group)
To set up all users who may use the shared service, you can use @ group to set all user accounts in the group group. The value of this option is a list, separated by spaces or commas between different items. When setting security = share, the password provided by the client to access a shared service will be authenticated one by one with all the users specified by this option. If a user's authentication is passed, the shared service will be accessed with that user's authority, otherwise the client will be denied access (setting security = share does not allow visitors to visit, only guest ok = yes allows visitors to visit, remember! ).
Valid users = user (@ group)
Sets the users and groups that can use the shared service, whose values are in the same format as the user option.
Invalid users = user (@ group)
Sets the users and groups that cannot use the shared service, whose values are in the same format as the user option.
Read list = user (@ group)
Set users and groups that only have read access to the shared service, whose values are in the same format as the user option.
Write list = user (@ group)
Sets the users and groups that have read and write access to the shared service, whose values are in the same format as the user option.
Admin list = user (@ group)
Sets the users and groups that have administrative privileges on the shared service, whose values are in the same format as the user option.
Public = yes | no
Set whether the shared service can be accessed by tourists. The synonym option is guest ok.
Create mode = mode
Mode is an octal value, such as 0755, with a default value of 0744. The value specified by this option is used to filter the access permissions of the new file. The default permission of the new file will be bitwise and manipulated with the value specified by create mode, and the result will be bitwise or manipulated with the value specified by force create mode. The result is the access permission of the new file.
Force create mode = mode
Mode is an octal value, and the default is 0000. Its function refers to the option create mode.
Directory mode = mode
Mode is an octal value, and the default is 0755. The value specified by this option is used to filter the access permission of the new directory. The default permission of the new directory will be bitwise and manipulated with the value specified by directory mode, and the result will be bitwise or manipulated with the value specified by force directory mode. The result is the access permission of the new directory.
Force directory mode = mode
Mode is an octal value, and the default is 0000. The role of this option refers to the option directory mode.
Force user = user
Forces the property onwer of the newly created file to be set. If there is a directory that allows guest to write, guest can be deleted. However, if you set force user to another user and set create mode = 0755, gues users cannot delete their newly created files.
At this point, the study on "the steps to install and configure Samba server in Linux system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.