Easily play with Samba servers in Linux

Source: Internet
Author: User
I. samba concepts and functions Samba is a software that allows Linux systems to Apply Microsoft network communication protocols. SMB is short for ServerMessageBlock, that is, Server Message Block, SMB is mainly used as Microsoft's network communication protocol. Samba then applied the SMB communication protocol to the Linux system, forming the current Samba software. Later, Microsoft renamed smb cifs (CommonInternetFile

I. samba concepts and functions

Samba is a software that allows Linux systems to Apply Microsoft network communication protocols. SMB is short for Server Message Block, that is, Server Message Block. SMB is mainly used as Microsoft network communication protocol, later, Samba applied the SMB communication protocol to the Linux system, forming the current Samba software. Later, Microsoft renamed smb cifs (Common Internet File System), a public Internet File System, and added many new features, this makes Samba more powerful.

Samba can be used for file sharing and print sharing between Linux and windows systems. Samba can be used for file sharing between windows and Linux, it can also be used for resource sharing between Linux and Linux. Because NFS (Network File System) can well achieve data sharing between Linux and Linux, therefore, Samba is mostly used for data sharing between Linux and windows.

SMB is a client/server-based protocol. Therefore, a Samba server can act as both a file sharing server and a Samba client. For example, A Samba server has been set up in Linux, and the windows client can share the resource files on the Samba server through the SMB protocol. At the same time, the Samba server can also access files shared by other windows or Linux systems on the network.

Samba uses the NetBIOS protocol in windows. If you want to use files shared in Linux, check whether the NetBIOS protocol is installed in your windows system.

Ii. installation and configuration of Samba

Our system environment is:

Operating System: Red Hat Enterprise Linux Server release 5.1

Samba Server IP Address: 192.168.60.231

Samba: samba-3.0.23c-2

1. Install samba

By default, samba packages are provided in almost all Linux releases. log on to the system and check whether Samba software is installed. perform the following operations:

[Root @ localhost ~] # Rpm-q samba

Samba-3.0.23c-2

If any display is displayed, Samba has been installed. If no display is displayed, go to the system disk to find the corresponding Samba package and install it.

The Installation Process of Samba is as follows:

[Root @ webserver ~] # Rpm-ivh samba-3.0.23c-2.i386.rpm

Warning: samba-3.0.23c-2.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186

Preparing... ######################################## ### [100%]

1: samba ####################################### #### [100%]

After the Samba server is installed, the configuration file directory/etc/samba and other samba executable command tools,/etc/samba/smb will be generated. conf is the core configuration file of samba,/etc/init. d/smb is the startup/Close file of samba.

2. composition and use of the Samba Service

There are two services for running Samba: SMB and NMB. SMB is the core startup service of Samba. file sharing can be realized only when the SMB service is started, the NMB service is used for resolution. Similar to the DNS implementation function, NMB can correspond the workgroup name shared by the Linux system to its IP address. If the NMB service is not started, you can only access shared files through IP addresses.

For example, if the IP address of a Samba server is 192.168.60.231 and the corresponding workgroup name is ixdba, you can enter the following two commands in the Windows IE browser to access the shared file. In fact, this is how to view the file shared by the Linux Samba server in Windows.

\ 192.168.60.231 \ shared directory name

\ Ixdba \ shared directory name

You can start, disable, and restart the Samba service through/etc/init. d/smb start/stop/restart. The following shows how to start the SMB service:

[Root @ localhost Linuxdata] #/etc/init. d/smb start

Starting SMB services: [OK]

Starting NMB services: [OK]

From the output of startup, we can see that SMB startup includes two services: SMB and NMB.

When Linux is used as the client, how should we check the files shared by other Linux Samba servers? This requires the tool smbclient. This command is provided by default. Common usage of Smbclient is as follows.

(1) view the sharing information of the Samba server

Smbclient-L // ip address of the Samba server-U Samba User Name

"-L" indicates the meaning of list, and "-U" indicates the user. If the Samba server has no password for access, you can omit "-U Samba user name ".

For example, when samba requires a password to log on, the sharing method is as follows:

[Root @ web ~] # Smbclient-L // 192.168.60.231/Linuxdata-U admin

Password: Enter the admin Password here.

When Samba has no password, run the following command:

[Root @ web ~] # Smbclient-L // 192.168.60.231/Linuxdata

Password: Press enter.

(2) log on to the Samba server

To log on to the Samba server on a Linux client, use the following code:

Smbclient // ip address of the Samba server-U Samba User Name

See the following operations:

[Root @ web samba] # smbclient // 192.168.60.231/Linuxdata

Password:

Domain = [IXDBA. NET] OS = [Unix] Server = [Samba 3.0.23c-2]

Server not using user level security and no password supplied.

Smb: \> ls

. D 0 Thu Feb 19 23:49:33 2009

.. D 0 Thu Feb 19 19:05:24 2009

Install. log 36563 Thu Feb 19 23:49:22 2009

Install. log. syslogs 4295 Thu Feb 19 23:49:22 2009

58113 blocks of size 262144. 44294 blocks available

Smb: \>? # Input here? You can view all the commands available on the smb command line.

? Altname archive blocksize cancel

Case_sensitive cd chmod chown close

Del dir du exit get

Getfacl hardlink help history LCD

Link lock lowercase ls mask

Md mget mkdir more mput

Newer open posix posix_open posix_mkdir

Posix_rmdir posix_unlink print prompt put

Pwd q queue quit rd

Recurse reget rename reput rm

Rmdir showacls setmode stat symlink

Tar tarmode translate unlock volume

Vuid wdel logon listconnect showconnect

!

Smb: \>

Have you seen it? It is similar to logging on to the FTP server. After logging on to the Samba server, you can upload and download files. If you have sufficient permissions, you can modify files.

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.