How to build a samba server to share Linux and Windows

Source: Internet
Author: User
Tags bit set
How to Set up a samba server to share information between Linux and Windows-Linux Enterprise Application-Linux server application information is as follows. In many cases, I do not want to access Linux through ftp or telnet, but I want to directly search for the IP address of the \ Linux host in the network neighbor or enter "\ Linux host IP Address" in the running state. Is that all I need to do? Of course, you only need to install samba.

Edit the configuration file smb after installation. conf, set the hosts allow in it. for example, if the IP address of your Windows host is 192.168.120.1 and the IP address of the Linux host is 192.168.120.2, hosts allow will write "192.168.120."
The next step is to use the smbadduser command to set the user name and password for accessing Linux. The format of the smbadduser command is:
Smbadduser unixid
Unixid must be a Linux User, such as root, and winid must be the user name in Windows.
It should be said that the setting is quite simple, and smbclient and smbmount commands and other commands starting with smb are very good.
Note that the host name must be used when the smbclient accesses the Windows system. For example:
Smbclient // Windows/share
IP address unavailable:
Smbclient // 192.168.120.1/share. In addition, if your Windows host is Windows 98 and you want to access the Linux system, you must log on to Windows 98 with the user name in Linux, because Windows 98 does not prompt you to enter the password!

You can access a linux host or a windows host.

If samba is installed and running on your computer, run the following smbclient command:
Usage: smbclient service [options]
Version 2.2.1a
-S smb. conf pathname to smb. conf file
-O socket_options socket options to use
-R name resolve order use these name resolution services only
-M host send a winpopup message to the host
-I scope use this NetBIOS scope
-N don't ask for a password
-N netbios name. Use this name as my netbios name
-D debuglevel set the debuglevel
-P connect to service as a printer
-P port connect to the specified port
-L log basename. Basename for log/debug files
-H Print this help message.
-I dest IP use this IP to connect
-E write messages to stderr instead of stdout
-U username set the network username
-L host get a list of shares available on a host
-T terminal code terminal I/o code {sjis | euc | jis7 | jis8 | junet | hex}
-M max protocol set the max protocol level
-A filename get the credentials from a file
-W workgroup set the workgroup name
-TIXFqgbNan command line tar
-D directory start from directory
-C command string execute semicolon separated commands
-B xmit/send buffer changes the transmit/send buffer (default: 65520)
The four convenient and easy-to-use small software introduced here will make it very easy to find "Network neighbors.
Gnomba ?? Quick action
This graphic tool allows you to scan SMB-based computers in subnets in different regions. The speed is faster than that of Windows 9X when "Network Neighbor" is enabled.
At the site http://gnomba.darkcorner.net/you can go to the ..z?compressed package or RPM file "gnomba-0.6.2-1.i386.rpm ". To Install an RPM file, right-click the file manager in X-Window and select "Install. The RPM file size is 166KB, and the compressed package must be unpacked before installation. In the "Terminal" window, we can do this:
# Tar-zxf gnomba-0.6.2.tar.gz
# Cd gnomba-0.6.2
#./Configure
# Make
# Make install
After successful installation, an executable document gnomba is generated in the/usr/bin directory, double-click it in the Document Manager or directly type the "gnomba" command in "Terminal" to start the software.


The specific explanation is as follows: (about accessing and operating shared resources)
1. If you want to access a windows Server, run the following command:
Smbclient // computer name/shared directory-U Login Name
Note: For windows, if it is completely shared or shared without a password, you can leave the '-U login name' empty. You can press enter to skip the prompt 'password. Otherwise, enter the password.
2. If the recipient is Linux/Unix and samba is set to share, no password or user name is required. If it is a user or security-level sharing, it is required.
3. Be sure to specify the shared directory name you want to access to log on. Otherwise, the system always prompts "Invalid network name in tree connect ".
4. The interface after entering is very similar to the ftp interface. You can also use get, put, and other commands, as well as tar.
In addition, smbclient-L host is used to view the available resources. For example, I used smbclient-L Linux01.
The following result is displayed:
Added interface ip = 202.38.207.123 bcast = 202.38.207.255 nmask = 255.255.255.0
Password: Sharename Type Comment
--------------------
ENSOFT Disk
CDROM Disk
SHARE Disk
UNUSED Disk
WORK Disk
FUN Disk
BACKUP Disk
IPC $ IPC remote inter-process communication Server Comment
--------- ------- Workgroup Master
----------------
In this example, an IPC indicates that a password is required for access.

If you think this is still too troublesome, you should often use smbclient commands!
Then you can run the smbmount command to mount the shared resources to your directory, for example:
Smbmount // Linux01/cdrom/mnt/cdrom

Mount-t smbfs // Linux01/cdrom/mnt/cdrom
At this time, my/mnt/cdrom directory is something in the optical drive on Linux01. Just like operating your own resources. Note:
For samba configuration, pay attention to the parameter "netbios name = your sharing name. I remember that this parameter is not used by default. You only need to add it before groupname.
If X-windows is used, open the browser and enter the smb address: // NeibogousName.

Linux network connection problems
How can I connect a computer with a linux operating system to the Internet? Can I connect a linux computer with a windows operating system? If so, how can we connect? Yes! Linux is a network system. It can be imagined that if it cannot be connected, it will be useless!
Internet connection can be simply described here!
For a graphical interface, find the network sub-menu in the start Menu equivalent to win, and set the auxiliary software to win's dial-up Internet access! 1. Yes, and supports many protocols such as tcp, udp, ftp, smtp, snmp...
2. If you want to use windows sharing, install and start the samba service in linux. Yes. Most of the protocols are supported. You can also set it in X-widows to Access windows Network neighbors through samba or through ftp or telnet.
You can check http: // 211.71.69.201/joyfre/
Uses Samba on linux or uses telnet or ssh from windows client to Linux server with komba2 can access win2000, very intuitive http: // www.linuxeden.com/download/softdetail.php? Softid = 164 ======>
If you want to make it simple, install MKLinux8.2, which is almost easy.
However, this is not helpful for you to learn the underlying layer or programming in the future!
Read more samba books,
SAMBA is better.
// Designed by ZhouLifa on April 29,200 2
// If any bug found, please inform me as soon as possible!
// Contact info:
// Post addr: Zhou Lifa, computer research institute, South China University of Technology, Tianhe District, Guangzhou 510640
// Computer Application Research Institution, South China University of Technology
// E-mail: zhoulifa@yahoo.com
// Tel: 020-87113239-9322
Samba configuration (smb. conf)
1. file format description:
The entire file is composed of multiple parameters, such as a dry segment. each segment starts with a segment name enclosed by square brackets ([]) and ends with smb. the start or end of the next segment of the conf file.
The file is a basic unit of behavior. In addition to the segment name or comment line, each row is in the format of name = value. The segment name and variable name (name) in the file are case-insensitive.
Behavior comment line starting with '#' or. spaces before and after the equal sign are ignored. but the spaces at the beginning and end of each line are unreliable. the space in the variable value (value) is assigned to the variable (name)
If a row ends with '\', it indicates that the row is not complete and the next row continues.
The variable value is either a character or a logical value: yes/no, true/false, 1/0
2. General configuration instructions:
Look at this Code:
[Share]
Path =/home/guest
Writeable = true
This will share your/home/guest directory with you as share. that is, if someone else sees the share directory of your computer in the network neighbor, the content is in/home/guest. this directory is writable.
Let's look at this section again:
[Doc]
Path =/home/pub
Writeable = false
Printable = true
Guest OK = true
This allows you to view the contents of your/home/pub directory as a guest, and you can also write or print the contents. Of course, the shared name is doc.
You can also share your printer with everyone:


[Printers]
Path =/usr/spool/public
Guest OK = yes
Printable = yes


Let's look at this section again:


[Zhoulifa]
Comment = zhoulifa's Printer
Valid users = zhoulifa
Path =/home/zhoulifa
Printer = zhoulifa_printer
Public = no
Writable = no
Printable = yes



This section has a shared directory named zhoulifa, which only allows zhoulifa access and can be printed.



[Homes]
Comment = homes's files share

Valid users = % S

Path =/home/% S

Public = no
Writable = yes

3. Description of each section:
Generally, the [global] segment does not need to be changed much, but you must design a workgroup and set a netbios name = your shared name under it so that you can see it in your network neighbors.
Note that the parameter netbios name does not exist by default. You must configure the parameter.
In addition, security can be designed to any value, which can be set later through valid users.
[Home] section: if you do not allow linux users to share your resources, the [home] section can be completely excluded, that is, although you have a user name and password for logging on to linux, you cannot access the shared content, if there is a home segment, each linux user can see the shared resources in addition to the other peripherals in samba, there are also things in his home. 4. let's take a look at my smb. conf:
# This is the main Samba configuration file. You shoshould read
# Smb. conf (5) manual page in order to understand the options listed
# Here. Samba has a huge number of retriable options (perhaps too
# Success !) Most of which are not shown in this example
#
# Any line which starts with a; (semi-colon) or a # (hash)
# Is a comment and is ignored. In this example we will use #
# For commentry and a; for parts of the config file that you
# May wish to enable
#
# NOTE: Whenever you modify this file you should run the command "testparm"
# To check that you have not made any basic syntactic errors.
#
#====================================== Global Settings ==================== ======================================
[Global]
# Workgroup = NT-Domain-Name or Workgroup-Name
Workgroup = Linux
Netbios name = Linux00 // the key is to add this
# Server string is the equivalent of the NT Description field
Server string = Samba Server (UnicomServer)
# This option is important for security. It allows you to restrict
# Connections to machines which are on your local network.
# Following example restricts access to two C class networks and
# The "loopback" interface. For more examples of the syntax see
# The smb. conf man page
; Hosts allow = 192.168.1. 192.168.2. 127.
# If you want to automatically load your printer list rather
# Than setting them up individually then you'll need this
Printcap name =/etc/printcap
Load printers = yes
# It shoshould not be necessary to spell out the print system type unless
# Yours is non-standard. Currently supported print systems include:
# Bsd, sysv, plp, lprng, aix, hpux, qnx
Printing = lprng
# Uncomment this if you want a guest account, you must add this to/etc/passwd
# Otherwise the user "nobody" is used
; Guest account = pcguest
# This tells Samba to use a separate log file for each machine
# That connects
Log file =/var/log/samba/% m. log
# Put a capping on the size of the log files (in Kb ).
Max log size = 0
# Security mode. Most people will want user level security. See
# Security_level.txt for details.
Security = user
#============================ Share Definitions ========== ==================================
[Homes]
Comment = Home Directories
Browseable = no
Writable = yes
Valid users = % S
Create mode = 0664
Directory mode = 0775
# If you want users samba doesn' t recognize to be mapped to a guest user
; Map to guest = bad user
# Un-comment the following and create the netlogon directory for Domain Logons
; [Netlogon]
; Comment = Network Logon Service
; Path =/usr/local/samba/lib/netlogon
; Guest OK = yes
; Writable = no
; Share modes = no
# This one is useful for people to share files
[Guest]
Comment = Temporary file space
Path =/guest
Read only = no
Public = yes
# A publicly accessible directory, but read only, cannot t for people in
# The "staff" group
; [Public]
; Comment = Public Stuff
; Path =/home/samba
; Public = yes
; Writable = yes
; Printable = no
; Write list = @ staff
# Other examples.
#
# A private printer, usable only by fred. Spool data will be placed in fred's
# Home directory. Note that fred must have write access to the spool directory,
# Wherever it is.
; [Fredsprn]
; Comment = Fred's Printer
; Valid users = fred
; Path =/home/fred
; Printer = freds_printer
; Public = no
; Writable = no
; Printable = yes
# A private directory, usable only by fred. Note that fred requires write
# Access to the directory.
; [Fredsdir]
; Comment = Fred's Service
; Path =/usr/somewhere/private
; Valid users = fred
; Public = no
; Writable = yes
; Printable = no
# A service which has a different directory for each machine that connects
# This allows you to tailor configurations to incoming machines. You cocould
# Also use the % U option to tailor it by user name.
# The % m gets replaced with the machine name that is connecting.
; [Pchome]
; Comment = PC Directories
; Path =/usr/local/pc/% m
; Public = no
; Writable = yes
# A publicly accessible directory, read/write to all users. Note that all files
# Created in the directory by users will be owned by the default user, so
# Any user with access can delete any other user's files. Obviously this
# Directory must be writable by the default user. Another user cocould of course
# Be specified, in which case all files wocould be owned by that user instead.
; [Public]
; Path =/usr/somewhere/else/public
; Public = yes
; Only guest = yes
; Writable = yes
; Printable = no
# The following two entries demonstrate how to share a directory so that two
# Users can place files there that will be owned by the specific users. In this
# Setup, the directory shocould be writable by both users and shocould have
# Sticky bit set on it to prevent abuse. obviusly this cocould be extended
# As required users as required.
; [Myshare]
; Comment = Mary's and Fred's stuff
; Path =/usr/somewhere/shared
; Valid users = mary fred
; Public = no
; Writable = yes
; Printable = no
; Create mask = 0765 /*********************************** *****************************/
// Designed by ZhouLifa on April 29,200 2
// If any bug found, please inform me as soon as possible!
// Contact info:
// Post addr: Zhou Lifa, computer research institute, South China University of Technology, Tianhe District, Guangzhou 510640
// Computer Application Research Institution, South China University of Technology
// E-mail: zhoulifa@yahoo.com
// Tel: 020-87113239-9322
In addition, the use of samba client and other tools:
(1) view network resources: smbclient-L // name of the computer on which the network is located
The list includes available resources, that is, whether to log on with the password. IPC $. For example:
Sharename Type Comment
--------------------
Guest Disk Temporary file space
IPC $ IPC Service (Samba Server (UnicomServer ))
ADMIN $ Disk IPC Service (Samba Server (UnicomServer ))
Server Comment
----------------
LINUX00 Samba Server (UnicomServer)
LINUX01 Linux01
Workgroup Master
----------------
LINUX LINUX01
This shows that the Linux computer in the Linux Group has a guest directory that can be shared, but the password. IPC $ description is required. There are also available resources in the same group.
(2) Access Network Resources: smbclient // computer name/directory name
To use the password, use smbclient // computer name/directory name-U username.
The interface after entering is similar to the ftp interface. commands that can be used are similar, such as get and put, and tar commands are available.
(3) Use remote things as your own: smbmount // computer name/directory name/local directory
For example, if you do not have an optical drive, you can mount the drive of others: smbmount/Linux01/cdrom/mnt/cdrom.
Of course, the premise is that the other party (Linux01) has shared the optical drive. After you enter the local directory (/mnt/cdrom), you will see what is in the other party's directory (cdrom. you do not need to get in smbclient.
Note: smbumount/local directory is used up.
(4) package others' things to your smbtar. It's easy. Let's see man's help. up! Gz!
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.