热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何搭建samba服务器使Linux和Windows互相共享

如何搭建samba服务器使Linux和Windows互相共享--Linux企业应用-Linux服务器应用信息,下面是详情阅读。
很多情况下不想通过ftp/telnet等方式访问Linux,而想在网上邻居里面直接查找或者在运行里面输入"\\Linux主机的IP地址"这样来访问,可以吗?当然可以,只要安装samba就可以了.

安装后编辑配置文件smb.conf,设置好里面的hosts allow就可以了.比如你的Windows主机的IP地址是192.168.120.1而Linux主机的IP地址是192.168.120.2,则 hosts allow这里要写"192.168.120."
  下一步就要通过smbadduser命令来设置访问Linux的用户名和密码了,smbadduser命令的格式是:
smbadduser unixid
unixid必须是Linux的系统用户,比如root,而winid是Windows系统下的用户名.
应该说设置是相当简单的,还有smbclient和smbmount命令等以smb开头的命令都很好.
要注意一下:smbclient访问Windows系统时一定要用hostname(主机名),比如:
smbclient //Windows/share
不能用IP地址:
smbclient //192.168.120.1/share另外,如果你的Windows主机是Windows 98,如果要访问Linux系统,你必须用Linux下的用户名登录Windows 98,因为Windows 98不提示输入密码!

访问的可以是linux机器 也可以是windows

如果你的电脑上安装并运行了samba可以用smbclient命令:
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 to
-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)
这里介绍的四款非常方便、易用的小软件,会让你查找“网络邻居”马上变得简单无比。
Gnomba??动作迅速
这个图形工具允许你扫描不同区域子网内基于SMB协议的电脑,速度要快过Windows 9X在打开“网络邻居”时所做的扫描。
在网站http://gnomba.darkcorner.net/可以下...z”压缩包或者是 RPM文件“gnomba-0.6.2-1.i386.rpm”。RPM文件只需要在X-Window的文档管理器中右击鼠标,选择“Install”就可以正常安装了。RPM文件的大小是166KB,压缩包则需要先行解包才可以安装,在“Terminal”视窗中我们可以这样做:
#tar -zxf gnomba-0.6.2.tar.gz
  #cd gnomba-0.6.2
  #./configure
  #make
  #make install
成功安装后,在/usr/bin目录中会生成一个可执行文档gnomba,在文档管理器中双击它或者是在“Terminal”中直接键入“gnomba”指令就可以启动软件。


具体解释如下:(关于访问并操作共享资源)
1、如果你要访问一台windows可以用命令:
smbclient //计算机名/共享目录 -U 登录名
说明:windows上如果是完全共享或无密码的共享则可以不写'-U 登录名',紧接着提示'password:'时可以直接回车略过。否则有输入密码。
2、如果对方是Linux/Unix,并且samba设置的是share共享则无须密码和用户名,如果是user或security级别的共享则要了。
3、一定要指定你要访问的共享目录名称登录,否则总是提示“Invalid network name in tree connect”。
4、进去后的界面很象ftp的界面,你也可以用get,put等命令,还可以用tar等。
另外,smbclient -L host是用来查看有那些资源可用,比如我用: smbclient -L Linux01
得到如下结果:
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 远程进程间通信 Server Comment
--------- ------- Workgroup Master
--------- -------
其中有IPC的表示要密码才能访问。

如果你觉得这样还是太麻烦了,要经常用smbclient的命令不爽!
那你可以用smbmount命令把共享资源mount到自己的目录下,比如:
smbmount //Linux01/cdrom /mnt/cdrom

mount -t smbfs //Linux01/cdrom /mnt/cdrom
这时我的/mnt/cdrom目录就是Linux01上的光驱里的东西了。完全象操作自己的资源一样。注:
关于samba的配置主要注意一下“netbios name=你的共享名”这个参数。我记得默认的没有这个参数你要加到 groupname前面就可以了。
如果用的是X-windows,可以打开浏览器,输入地址 smb://NeibogousName 就行。

Linux连网问题
安有linux操作系统的计算机怎样连网,linux与windows操作系统能连网吗?如果能的话怎样连接?可以!linux就是一个网络系统,网络系统网络系统,可想而知,如果不能联网就废了!
联internet在这里可以简单的说一下!
如果是图形化界面,在相当于win的start菜单里找到网络子菜单,在里面有向win的拨号上网设置辅助软件!1、可以,且支持很多协议如tcp、udp、ftp、smtp、snmp...
2、如果想用windows的共享,则要在linux中安装并启动samba服务。可以,决大部分的协议都支持,在X-widows中也可以设置,可以通过samba访问windows网上邻居,也可以通过ftp和telnet
你可以看看http://211.71.69.201/joyfre/
的资料uses Samba on linux or uses telnet or ssh from windows client to Linux server用komba2可以访问win2000,很直观的http: //www.linuxeden.com/download/softdetail.php?softid=164=======>
如果你想简单的话,建议install MKLinux8.2,几乎手到擒来
但这样,对你学底层,和对以后编程没帮助!
多看一些samba的book,
SAMBA还比较好
//Designed by ZhouLifa on April 29, 2002
//If any bug found, please inform me as soon as possible!
//Contact info:
//post addr: 广州市天河区华南理工大学计算机研究所 周立发 510640
//Computer Application Research Institution, South China University of Technology
//e-mail: zhoulifa@yahoo.com
//Tel: 020-87113239-9322
samba配置(smb.conf)
1.文件格式说明:
整个文件有如干个段和多个参数构成. 每个段开头是方括号([ ])括起来的段名, 结束于smb.conf文件的下一个段开头或文件尾.
文件是以一个个行为基本单位的. 每个行除了是段名或注释行外格式全为:name=value. 并且文件里段名和变量名(name)不分大小写.
以'#'或';'开头的行为注释行.等号前后的空格是忽略的.但每一行开头和结尾的空格是不可靠的,最好不要.变量值(value)里的空格赋值给变量(name)
若一行以'\'结尾则表明此行未完,下一行继续此行.
变量值(value)要么是字符,要么是逻辑值yes/no, true/false, 1/0
2.一般配置说明:
看这一段代码:
[share]
path = /home/guest
writeable = true
这就把你的目录/home/guest作为share共享给大家.即别人在网上邻居里看到你的计算机的share目录,内容是/home/guest下的.并且此目录可写.
再看这一段:
[doc]
path = /home/pub
writeable = false
printable = true
guest ok = true
让大家可以以guest身份看到你的目录/home/pub目录的内容,并且可写也可打印其内容.当然共享名为doc了.
还可以把你的打印机共享给大家:


[printers]
path = /usr/spool/public
guest ok = yes
printable = yes


再看这一段:


[zhoulifa]
comment = zhoulifa's Printer
valid users = zhoulifa
path = /home/zhoulifa
printer = zhoulifa_printer
public = no
writable = no
printable = yes



这一段有了zhoulifa一个共享目录,此目录只允许zhoulifa访问,并且可打印.



[homes]
comment = homes's files share

valid users = %S

path = /home/%S

public = no
writable = yes

3.各段说明:
[global]段一般不需改动太多,但是你必需设计workgroup,并且要在它下面设置一个netbios name=你的共享名,使大家可以在网上邻居里看到你.
特别请大家注意的是默认好象没有netbios name这个参数的,你必需配置.
另外,security可以设计成任何的值,反正后来可以通过valid users来设定.
[home] 段:如果你不允许linux用户共享你的资源,[home]段可以全部不要,就是说虽然有登录linux的用户名和密码但不能用来访问共享内容,如果有 home段,那么每个linux用户可以看到的共享资源除了你在samba里另外设的外还有他的home里的东西.4.看一下我的smb.conf吧:
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options (perhaps too
# many!) 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 a #
# 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//关键是加入了这
# 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. The
# 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 should 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, except 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 could
# 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 could of course
# be specified, in which case all files would 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 should be writable by both users and should have the
# sticky bit set on it to prevent abuse. Obviously this could be extended to
# as many 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, 2002
//If any bug found, please inform me as soon as possible!
//Contact info:
//post addr: 广州市天河区华南理工大学计算机研究所 周立发 510640
//Computer Application Research Institution, South China University of Technology
//e-mail: zhoulifa@yahoo.com
//Tel: 020-87113239-9322
另外samba客户端等工具的使用:
(1)查看网络资源:smbclient -L //网上邻居计算机名称
列出的内容包括可用资源即是否要密码登录.IPC$说明要密码.例如:
Sharename Type Comment
--------- ---- -------
guest Disk Temporary file space
IPC$ 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
此显示了Linux组里的Linux01计算机有guest目录可以共享,但是要密码.IPC$说明的.同组还有Linux01有可用资源.
(2)享用网络资源:smbclient //计算机名/目录名
如果是要密码的你要用:smbclient //计算机名/目录名 -U username
进去后的界面象ftp界面.可以用的命令也差不多,get,put等,还有tar命令可用的.
(3)把远程的东西当自己的东西用:smbmount //计算机名/目录名 /本地目录
比如你没有光驱,那么可以把别人的光驱mount上来:smbmount //Linux01/cdrom /mnt/cdrom
当然前提是对方(Linux01)把光驱共享了,以后你进入本地目录(/mnt/cdrom)看到的就是对方目录(cdrom里的)里的东西了.不需在smbclient去get了.
注意:用完了要smbumount /本地目录
(4)将别人的东西打包给自己smbtar,简单了,自己看man帮助吧.up!gz!
推荐阅读
  • 原理:dismiss再弹出,把dialog设为全局对象。if(dialog!null&&dialog.isShowing()&&!(Activity.)isFinishing()) ... [详细]
  • Java学习笔记之使用反射+泛型构建通用DAO
    本文介绍了使用反射和泛型构建通用DAO的方法,通过减少代码冗余度来提高开发效率。通过示例说明了如何使用反射和泛型来实现对不同表的相同操作,从而避免重复编写相似的代码。该方法可以在Java学习中起到较大的帮助作用。 ... [详细]
  • 本文介绍了如何使用PHP向系统日历中添加事件的方法,通过使用PHP技术可以实现自动添加事件的功能,从而实现全局通知系统和迅速记录工具的自动化。同时还提到了系统exchange自带的日历具有同步感的特点,以及使用web技术实现自动添加事件的优势。 ... [详细]
  • 本文介绍了Python高级网络编程及TCP/IP协议簇的OSI七层模型。首先简单介绍了七层模型的各层及其封装解封装过程。然后讨论了程序开发中涉及到的网络通信内容,主要包括TCP协议、UDP协议和IPV4协议。最后还介绍了socket编程、聊天socket实现、远程执行命令、上传文件、socketserver及其源码分析等相关内容。 ... [详细]
  • 基于layUI的图片上传前预览功能的2种实现方式
    本文介绍了基于layUI的图片上传前预览功能的两种实现方式:一种是使用blob+FileReader,另一种是使用layUI自带的参数。通过选择文件后点击文件名,在页面中间弹窗内预览图片。其中,layUI自带的参数实现了图片预览功能。该功能依赖于layUI的上传模块,并使用了blob和FileReader来读取本地文件并获取图像的base64编码。点击文件名时会执行See()函数。摘要长度为169字。 ... [详细]
  • HDU 2372 El Dorado(DP)的最长上升子序列长度求解方法
    本文介绍了解决HDU 2372 El Dorado问题的一种动态规划方法,通过循环k的方式求解最长上升子序列的长度。具体实现过程包括初始化dp数组、读取数列、计算最长上升子序列长度等步骤。 ... [详细]
  • 本文讨论了Alink回归预测的不完善问题,指出目前主要针对Python做案例,对其他语言支持不足。同时介绍了pom.xml文件的基本结构和使用方法,以及Maven的相关知识。最后,对Alink回归预测的未来发展提出了期待。 ... [详细]
  • 本文讨论了如何优化解决hdu 1003 java题目的动态规划方法,通过分析加法规则和最大和的性质,提出了一种优化的思路。具体方法是,当从1加到n为负时,即sum(1,n)sum(n,s),可以继续加法计算。同时,还考虑了两种特殊情况:都是负数的情况和有0的情况。最后,通过使用Scanner类来获取输入数据。 ... [详细]
  • Mac OS 升级到11.2.2 Eclipse打不开了,报错Failed to create the Java Virtual Machine
    本文介绍了在Mac OS升级到11.2.2版本后,使用Eclipse打开时出现报错Failed to create the Java Virtual Machine的问题,并提供了解决方法。 ... [详细]
  • 本文详细介绍了Linux中进程控制块PCBtask_struct结构体的结构和作用,包括进程状态、进程号、待处理信号、进程地址空间、调度标志、锁深度、基本时间片、调度策略以及内存管理信息等方面的内容。阅读本文可以更加深入地了解Linux进程管理的原理和机制。 ... [详细]
  • 1,关于死锁的理解死锁,我们可以简单的理解为是两个线程同时使用同一资源,两个线程又得不到相应的资源而造成永无相互等待的情况。 2,模拟死锁背景介绍:我们创建一个朋友 ... [详细]
  • 动态规划算法的基本步骤及最长递增子序列问题详解
    本文详细介绍了动态规划算法的基本步骤,包括划分阶段、选择状态、决策和状态转移方程,并以最长递增子序列问题为例进行了详细解析。动态规划算法的有效性依赖于问题本身所具有的最优子结构性质和子问题重叠性质。通过将子问题的解保存在一个表中,在以后尽可能多地利用这些子问题的解,从而提高算法的效率。 ... [详细]
  • Java验证码——kaptcha的使用配置及样式
    本文介绍了如何使用kaptcha库来实现Java验证码的配置和样式设置,包括pom.xml的依赖配置和web.xml中servlet的配置。 ... [详细]
  • 如何在服务器主机上实现文件共享的方法和工具
    本文介绍了在服务器主机上实现文件共享的方法和工具,包括Linux主机和Windows主机的文件传输方式,Web运维和FTP/SFTP客户端运维两种方式,以及使用WinSCP工具将文件上传至Linux云服务器的操作方法。此外,还介绍了在迁移过程中需要安装迁移Agent并输入目的端服务器所在华为云的AK/SK,以及主机迁移服务会收集的源端服务器信息。 ... [详细]
  • iOS Swift中如何实现自动登录?
    本文介绍了在iOS Swift中如何实现自动登录的方法,包括使用故事板、SWRevealViewController等技术,以及解决用户注销后重新登录自动跳转到主页的问题。 ... [详细]
author-avatar
用户rmgq8prdxo
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有