Install samba source code in Linux (non-RPM package)

Source: Internet
Author: User
Linux samba source code installation (non-RPM package)-Linux general technology-Linux technology and application information, the following is a detailed description. First, learn some basics.
The core of samba is the two daemon processes smbd and nmbd, which run continuously from the server to the stop. Full use of Smbd and nmbd
All configurations are saved in the smb. conf file. Smb. conf describes the output to the smbd and nmbd daemon for sharing,
Share the output to whom and how to output. The role of the Smbd process is to process the incoming SMB software package.
In Linux, The nmbd process allows other hosts (or workstations) to browse Linux servers.
If you use rpm for installation, you do not need to use service smb start to start samba. You can also use service nmbd start and service smbd start.

In the smb. conf file, the Comment line starts with "#", and each Chinese and English letter is case-insensitive.
"\", Which can be divided into multiple rows. The line starting with ";" is a configuration that can be changed. When ";" is removed, this configuration will take effect.

[Global] (global parameter setting, which has a great impact on samba functions, is mainly used to set the overall system rules.
Workgroup = This is your domain in windows.
Server string = This is the explanation of samba in windows.
Netbios name = it is best to use your machine name. If you delete the sentence, the default name is your LINUX machine name. However, it is best to enter it by yourself.
Dos charset = cp936
Unix charset = cp936 can be correctly displayed with these two sentences.
Hosts allow allows you to log on to the linux-samba host list, which is provided by IP addresses. Multiple IP addresses are separated by spaces. hosts that are not in the list cannot obtain services provided by samba, this is also an aspect of network security.
Printcap name specifies the printcap file address, usually/etc/printcap, which contains the configuration information of the linux printer.
The default value of load printers is yes.
If the printer used by printing is non-standard, the printer system type should be specified.
Log file =/usr/local/samba/var/log. % m
Max log size = 0

The above two lines are definitions of Samba logs. The recorded file is stored in/var/log/samba/% m. log, the installation directory is different, the log can be different, the next one is to define the size of the log record file, unit is KB, if it is 0, it is not limited to size.
The guest acount guest Account indicates which Linux user is used as the target client connection and defines the Samba Default User Account. This account must be in/etc/passwd.

Security specifies the security mode. Most users use user-level security mode, and samba uses a local linux Password File for verification.

Security = security_level
Defines the security level of Samba, from low to high: share, user, server, domain. The verification methods are as follows:
Share: no security level. Any user can access resources on the server without a user name or password.
User: The default configuration of samba. Users must provide the user name and password for authentication before accessing shared resources.
Server: similar to the user security level, but the user name and password are submitted to another server for verification, for example, submitted to an NT server. If the submission fails, it is returned to the user security level.
Domain: This security level requires that a Windows primary domain controller exist on the network. samba submits the user name and password to it for verification.
The following three security levels require users to have system accounts on their linux machines. Otherwise, it cannot be accessed.
Smb passwd file =/etc/samba/smbpasswd (set the location of the smb password file)
Username map =/etc/smbusers
Encrypt passwords = no. Use the plaintext password for verification. If the password is encrypted, change it to yes.

I remember that one day of a month, I decided to install any software package only using the source code without rpm. Although it is very troublesome, it is helpful to understand the linux system.

First, create a document, install and configure samba, and write a tutorial.
Download the latest sambasource code package from www.samba.org. download samba-3.0.7.tar.gz and put it under/root/lova/samba in my directory.

Tar-zxvf samba-3.0.7.tar.gz unzip to get samba-3.0-7
Cd samba-3.0.7
Cat README: It's a pity that E is too bad to understand. Install it directly.
Find.-name configure
./Source/configure is originally hidden in this
Cd source/
Mkdir/usr/local/samba
./Configure -- prefix =/usr/local/samba/install to/usr/loca/samba
Make & make install
Cd/usr/local/samba/go to the installation directory.
Ls
Bin include lib man private sbin swat var has been installed successfully. How can I create
[Root --/usr/local/samba] mkdir etc
[Root --/usr/local/samba] cp ~ /Love/samba-3.0.7/examples/smb. conf. default./etc/smb. conf

Now let's look at our goal.
1. There is a shared directory that can only be read and cannot be changed.
2. There is a shared directory that anyone can make any changes, including adding directory files and deleting directory files.
3. Each user can view his/her own home directory, which cannot be viewed by other users, but cannot be changed.
4. There is A shared directory. People in group A can make any changes, while those in Group B can only read and those in group C cannot see it.
5. Each user can use a printer after logging on. (Failed ).

Objective 1 method 1
[Root -- ~] Cd/usr/local/samba/etc/
[Root --/usr/local/samba/etc] cp smb. conf beifen backup to avoid errors.
Modify smb. conf,
Change workgroup = MSHOME to the working group of your linux
Security = share
Add
[Read1]
Comment = read1
Path =/home/read1
Public = yes
Guest OK = yes
Writable = yes

Create shared directory
Whoami
Root
Umask
0022
Mkdir/home/read1
Cd! $
Cat>; linux
Hi linux
Ll/home/read1/
Total usage 4
-Rw-r -- 1 root 9 October 24 11:20 linux
644
Adduser nxgz; passwd! $; Create a system user
[Root -- ~] /Usr/local/samba/bin/smbpasswd-a nxgz then add this user as a samba user
Can't load/usr/local/samba // lib/smb. conf-run testparm to debug it: it seems that there is no smb under lib. conf, I will add it.
[Root -- ~] Cp/usr/local/samba/etc/smb. conf/usr/local/samba/lib/
[Root -- ~] /Usr/local/samba/bin/smbpasswd-a nxgz successfully added the samba user
New SMB password:
Retype new SMB password:
Startsmbfilepwent_internal: file/usr/local/samba // private/smbpasswd did not exist. File successfully created.
Added user nxgz.

[Root -- ~] Service iptables stop
Clear all links: [OK]
Delete a user-defined chain: [OK]
Reset the built-in chain to the default "ACCEPT" policy: [OK]
[Root -- ~] Service network restart
Closing interface eth0: [OK]
Disable the loop interface: [OK]
Set network parameters: [OK]
Pop-up loop interface: [OK]
Pop-up page eth0: [OK]
[Root -- ~] /Usr/local/samba/sbin/smbd-D start two samba Processes
[Root -- ~] /Usr/local/samba/sbin/nmbd-D
Go to Windows-xp, open the computer, find the address, enter the \ linux host name, and find the shared directory read.

Method 2
Add the following at the end of smb. conf:
[Read2]
Comment = read2
Path =/home/read2
Public = yes
Read only = yes
Mkdir/home/read2; cd! $; Cat>; linux; chmod-R 777/home/read2; create shared directories and modify permissions
Then
Service iptables stop
Service network restart
/Usr/local/samba/sbin/smbd-D
/Usr/local/samba/sbin/nmbd-D
We cannot see the shared read2 in win-xp.
It may be that there is a problem with smb. conf. Let's check it with testparm.
[Root -- ~] Testparm
Bash: testparm: command not found does not enter the complete path.
[Root -- ~] /Usr/local/samba/bin/testparm
Load smb config files from/usr/local/samba // lib/smb. conf
Processing section "[homes]"
Processing section "[printers]"
Processing section "[read]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
There is no read2. Let's take a closer look at the first line, Load smb config files from/usr/local/samba // lib/smb. conf, as if the testpart tool is based on lib/smb. the smb in lib. smb under conf and etc. conf is completely different, because we have added read2, And we can copy and overwrite it.
Cp-f/usr/local/samba/etc/smb. conf/usr/local/samba/lib/
Then
Service iptables stop
Service network restart
/Usr/local/samba/sbin/smbd-D
/Usr/local/samba/sbin/nmbd-D
Go back to win-xp and you can find it. Haha, okay. Although its permission is 777, it is controlled by read only and cannot be deleted or added.
Target 1 successful

Since every modification to/usr/loca/samba/etc/smb. conf is complete
Cp-f/usr/local/samba/etc/smb. conf/usr/local/samba/lib/
Then
Service iptables stop
Service network restart
/Usr/local/samba/sbin/smbd-D
/Usr/local/samba/sbin/nmbd-D

We can write a shell
Emacs samba. sh
Cp-f/usr/local/samba/etc/smb. conf/usr/local/samba/lib/
Service iptables stop
Service network restart
/Usr/local/samba/sbin/smbd-D
/Usr/local/samba/sbin/nmbd-D
After modification, you can
1, sh samba. sh
2, sh <samba. sh
3, chmod 777 samba. sh
Mv samba. sh ~ /Bin
Samba. sh
All three methods are supported.

Goal 2,
The above remains unchanged. Add it at the end of smb. conf.
[Write]
Comment = write
Path =/home/write
Public = yes
Guest OK = yes
Writable = yes

Mkdir/home/write; cd/home/write; cat & gt; linux; chmod-R 777/home/write/; sh <samba. sh creates shared directory files, opens permissions, and restarts the service.
Read in the read directory under win-xp, delete, add, and change the original file in write. The target 2 is completely correct. Let's try Chinese again. Open the write directory of linux under win-xp, find and edit linux, add Chinese, and create a Chinese directory under the write directory, go back to linux and check whether the results can display Chinese characters normally. After editing the results, the Chinese characters in linux can be displayed normally, and the Chinese directories are garbled. How can this problem be solved.
Add
Dos charset = cp936
Unix charset = cp936 I added it to security = share.
In Windows-xp, open write to add a Chinese directory and go back to linux to check that the Chinese directory can be correctly recognized.

Goal 3,
Create several samba users.
Adduser sambau001; passwd! $;/Usr/local/samba/bin/smbpasswd-a sambau001
Add sambau002 and sambau003 users using the above method
Separately su these users, add the file linux, and then modify smb. conf, change security = to user. Please restart win this time. Because the user is added, enter the user and password and you will be able to see your directory.
My home is as follows
[Homes]
Comment = home
Browseable = no
Writable = yes
Valid users = % S
Create mode = 0664
Directory mode = 0775
Use a user to enter, create a file under win-xp, a directory, and create another file in the directory. in linux, use this user to enter your target, you can see the created file directory. The File Permission is 664, And the directory permission is 775.
Target 3 is successful.


Goal 4,
Create three groups
Groupadd sambag001; groupadd sambag002; groupadd sambag003
Usermod-g sambag001 sambau001; usermod-g sambag002 sambau002; usermod-g sambag003 sambau003 Add the three users to the three groups respectively.

Mkdir share; cd share/; cat>; linux; chmod-R 777/home/share/Open permission, control it in smb. conf
User r in sambag001, user rw in sambag002, and user no in sambag003

Add the following to smb. conf:
[Share]
Comment = share
Path =/home/share
Public = no
Valid users = @ sambag001, @ sambag002
Invalid users = @ sambag003
Write list = @ sambag002
Add it to win-xp and try again.
Those not listed cannot be entered.
Among them, valid userd is used to list only the r permission. If a; number is added before the write list, users in sambag001 and users in sambag002 can only view it.


[] Contains the specified sharing name, which is generally the name of the folder that can be seen in the network neighbor.
Comment refers to the remarks on share change.
Path specifies the shared path
Allow hosts and deny hosts are the same as the previous global settings.
Writeable specifies whether the directory is writable by default.
Users can set all users who may use the shared resource or use @ group to represent all members of the group. Different projects are separated by spaces or commas.
Valid users specifies the users and groups that can view the shared resource.
Invalid users indicates that users and groups of the shared resource cannot be viewed.
Read list specifies users and groups that can only read the shared resource.
Write list specifies the users and groups that can read and write the shared resource.
Admin list specifies the users and groups that can manage the shared resources (including read/write and permission granting.
Public indicates whether the shared resource can be accessed by the visitor's account. This switch is also called guest OK. Therefore, guest OK = yes in some configuration files is actually the same as public = yes.
Create mode indicates the attributes of the newly created file, which is generally 0755.
Directory mode indicates the attribute of the newly created directory, which is generally 0755.
Force user forces the owner of the file to be created. If I have a directory that allows the guest to be written, the guest can be deleted. If I use force user = grind to force the object to be created, the owner is grind, and the create mask = 0755, in this way, the guest cannot be deleted.

Browseable specifies whether other users can browse the user's home directory. Of course, it is not allowed, so it is set to no.
Writable enables the user to access this directory when reading and writing files in the main directory, the value is yes, only the read permission should be set to no.

Xp successfully accessed linux. Try again
Use # smbclinet "\\\\ nxgz \ shared directory name"
You can log on to the windows Host nxgz like telnet or ftp. You must enter the password when entering the password.
Then the smb: \>;


The following command fails to be installed in the source code. {{
Smbmount // test/share/pub linux mounted to windows Directory
Mount-t smbfs-o username = WINDOWS Host login name, password = password // PC-NAME/SHARE-DIR/mnt/tmp
Share smbmount // testsamba/pub linux with linux
Add directories and users
1. Add users one by one
Log on as a root user, add a Linux user, and set the password:
Adduser smbuser
Passwd smbuser
Add the user smbuser to the Samba server user and set the password:
Smbpasswd-a smbuser
2. join all users in the system
# Vi/etc/passwd (delete all users you don't need or you don't know)
# Cat/etc/passwd │ mksmbpasswd. sh>;/etc/samba/smbpasswd (add linux users to smb users)
# Smbpasswd test (set the smb access password of the test user)
#/Etc/rc. d/init. d/smb restart (restart samba)
3. Add part
# Smbadduser linuxname: 2000 name # Add a user
Use smbpasswd to specify a password for each user in the following format: (must be Root)
Smbpasswd userid: passwd userid2: passwd2 ......}}
Related Article

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.