Linux 网管 123 --- 第7章. 自订的组态及管理内容 -4.使用 Samba
2005-04-15 11:30:39 来源:WEB开发网核心提示:使用 Samba 进行 Windows型态的档案及列印服务 linux可以使用 Samba 套件提供 SMB 服务 (例如. WfW, Win95,及 NT型态的网路档案及列印分享),Linux 网管 123 --- 第7章. 自订的组态及管理内容 -4.使用 Samba, 这一节会描述如何组态分享,以及如何从客户端存
使用 Samba 进行 Windows型态的档案及列印服务
linux可以使用 Samba 套件提供 SMB 服务 (例如. WfW, Win95,及 NT型态的网路档案及列印分享)。
这一节会描述如何组态分享,以及如何从客户端存取这些服务。
Samba 套件包含在 Red Hat 发行版中,您可以检查是否安装以及其版本,键入:
rpm -q samba
如果尚未安装,您需要使用 RPM 公用程式安装它。 查看 第10章,使用 Red Hat 套件管理程式 (RPM)
一节 有关如何做的细节。
这些 Samba 档中您应该关心的最重要部分是:
/etc/smb.conf
Samba 组态档是分享及其他组态参数的设定 (查看下面)
/var/log/samba/
放 Samba log 档的地方
/home/samba/
建议应该设定的档案分享位置。 然而, 您应该选择一个符合足够您存放档案空间的地方。个人来说,
我常设定一个大的 partition 挂载在 /archive/ 下并且放我的分享档案。
``/etc/smb.conf'' 档包含了档案及列印分享的组态资讯。档案的开头几行包含了整体的组态方针,所
有的分享都相同 (除非他们超越了每一个独立分享的基础),其馀的是分享部分。
Samba 安装包括了一个预设的 smb.conf 档,可以满足您大多数的需求,且只需作稍微的修改。
这是这个档的 一些例 (我会大幅地自订它给您看看更多重要及有趣的部分):
# Items common to all shares (unless over-ridden on a per-share basis)
[global]
# Number of minutes of inactivity before client is disconnected
# to avoid consuming resources. Most clients will automatically
# reconnect so this is a good idea to enable.
dead time = 10
# Don't let users connect as “root”, just-in-case. :-)
invalid users = root
# Specify the account for guest shares (shares that don't require
# a passWord to connect to. This username must be a valid user
# in the /etc/passwd file.
guest account = guest
# Specify where log files should be written to. The “%m” suffix
# means that log files will be created in the format
# log.machine-name (eg. “log.twixel”)
log file = /usr/local/samba/logs/log.%m
# Maximum size of log file, in Kilobytes.
max log size = 1000
# Password level 3 means that case is not an issue when entering
# passwords. A little less secure than level 1 or 2 would be,
# but seems to be a fair comPRomise for user convenience.
password level = 3
# Specify that all shares should appear in the browse list
# (override any you don't want on a per-share basis).
browseable = yes
# If this is enabled, you can see active connections using the
# “smbstatus” command.
status = yes
# The level of debugging information that is recorded in the log
# files. Higher values generate more information (which is
# probably not very useful, most of the time).
debug level = 2
# This will send any Windows-style “POPUP” messages received on
# the server to the postmaster by e-mail. Not very useful, but
# an interesting demonstration of what can be accomplished.
message command = /bin/mail -s 'Message from %f on %m' postmaster < %s; rm %s &
# This is a form of caching that, when enabled, may improve
# performance when reading files.
read prediction = true
# A list of services that should be added automatically to the
# browse-list.
auto services = cdrom
# The location of your “printcap” file, a text file containing
# definitions for your printers.
printcap name = /etc/printcap
# If enabled all printers in the /etc/printcap file will be
# loaded into the browse-list.
load printers = yes
# The print command by which data is spooled to a printer under Linux.
print command = lpr -r -P%p %s
# The print command by which job queue information (printer status)
# can be obtained.
lpq command = lpq -P%p
# The print command by which unwanted print jobs can be deleted
# from the queue.
lprm command = lprm -P%p %j
# The level at which Samba advertises itself for browse elections.
# Currently set to a high value to give it an even “foot-hold” with
# any swarmy NT servers on the network. :-)
os level = 34
# These are user's personal shares. If the client's username matches on the
# server, they can access their home directory (provided they enter the
# correct password).
[homes]
# The comments appear in the browse list.
comment = Home Directories
# This matches the username of the client to that of the share.
# If they do not match, no share will be displayed in the browse
# list, or available to connect to.
user = %S
# The path to the share. For example, “smithj” would map to
# “/home/smithj”
path = /home/%S
# If enabled, allow read/write access to the shares.
writeable = yes
# Just an inverted synonym for “writeable”. We don't *really* need
# to use both. :-)
read only = no
# Keep this disabled so that a password is required to access these
# shares.
public = no
# We don't want this share (after all, it is private) to appear in
# the browse-list of other users.
browseable = no
# This is a publicly available print share, called “hp_laser”. It appears
# on the browse lists and can be accessed without a password by any client.
[hp_laser]
# The comment that appears in the browse-list.
comment = Main office printer (HP Laserjet 400)
# The username that this share is accessed as (guest means all users).
user = guest
# All generated print files will first be created in the /tmp
# directory.
path = /tmp
# Do not allow file creation except through print spooling.
writeable = no
# Set permissions accordingly -- root access to print jobs only.
create mode = 0700
# If this is enabled a password is not required to access the share.
public = yes
# This should be enabled to indicate that this is a printer share.
printable = yes
# Here is a service providing access to the CD-ROM device.
[cdrom]
comment = Shared CD-ROM drive on Linux
user = guest
path = /cdrom
writeable = no
read only = true
browseable = yes
public = yes
guest ok = yes
小技巧: 最近的 Samba 版本, 从 2.0 以後,提供了一个非常灵活以网页为基础的组态公用程式叫做``swat'',
可以使得组态过程更为友善。这个公用程式倾听伺服器上的 TCP port 901 ,所以要使用的话必须将您的浏览器
指向下面的位址:
mydomain.name:901
(当然如果要使用 SWAT 的话您需要让网页伺服器执行,像是 Apache。 查看 第7章,网页伺服器及 HTTP 快取代理
主机管理 一节 有关细节。)
最新版的 Samba 和 2.0 版之前的相比增加了很多功能。 升级到这个版本是值得的。
客户端必须有 TCP/ip network stack 以连接分享。更进一步,为了浏览工作,TCP/IP 协定必须 bound 到
NETBEUI。在 Windows 95 可以由控制台中的``网路''进行组态。
假设客端已经正常地组态好, 您应该可以看到伺服端的分享出现在“网路上的芳邻” (或如果您不是使用
Windows 95/NT的相等的方案)。您可以从网路上的芳邻对映到网路磁碟,或键入到分享的绝对路径
(例如. “\\mail\cdrom”)。 如果分享服务需要键入密码,您会被提示。
更多有关 Samba的资料可以在 Samba Home Page http://samba.anu.edu.au/samba/中找到。
linux可以使用 Samba 套件提供 SMB 服务 (例如. WfW, Win95,及 NT型态的网路档案及列印分享)。
这一节会描述如何组态分享,以及如何从客户端存取这些服务。
Samba 套件包含在 Red Hat 发行版中,您可以检查是否安装以及其版本,键入:
rpm -q samba
如果尚未安装,您需要使用 RPM 公用程式安装它。 查看 第10章,使用 Red Hat 套件管理程式 (RPM)
一节 有关如何做的细节。
这些 Samba 档中您应该关心的最重要部分是:
/etc/smb.conf
Samba 组态档是分享及其他组态参数的设定 (查看下面)
/var/log/samba/
放 Samba log 档的地方
/home/samba/
建议应该设定的档案分享位置。 然而, 您应该选择一个符合足够您存放档案空间的地方。个人来说,
我常设定一个大的 partition 挂载在 /archive/ 下并且放我的分享档案。
``/etc/smb.conf'' 档包含了档案及列印分享的组态资讯。档案的开头几行包含了整体的组态方针,所
有的分享都相同 (除非他们超越了每一个独立分享的基础),其馀的是分享部分。
Samba 安装包括了一个预设的 smb.conf 档,可以满足您大多数的需求,且只需作稍微的修改。
这是这个档的 一些例 (我会大幅地自订它给您看看更多重要及有趣的部分):
# Items common to all shares (unless over-ridden on a per-share basis)
[global]
# Number of minutes of inactivity before client is disconnected
# to avoid consuming resources. Most clients will automatically
# reconnect so this is a good idea to enable.
dead time = 10
# Don't let users connect as “root”, just-in-case. :-)
invalid users = root
# Specify the account for guest shares (shares that don't require
# a passWord to connect to. This username must be a valid user
# in the /etc/passwd file.
guest account = guest
# Specify where log files should be written to. The “%m” suffix
# means that log files will be created in the format
# log.machine-name (eg. “log.twixel”)
log file = /usr/local/samba/logs/log.%m
# Maximum size of log file, in Kilobytes.
max log size = 1000
# Password level 3 means that case is not an issue when entering
# passwords. A little less secure than level 1 or 2 would be,
# but seems to be a fair comPRomise for user convenience.
password level = 3
# Specify that all shares should appear in the browse list
# (override any you don't want on a per-share basis).
browseable = yes
# If this is enabled, you can see active connections using the
# “smbstatus” command.
status = yes
# The level of debugging information that is recorded in the log
# files. Higher values generate more information (which is
# probably not very useful, most of the time).
debug level = 2
# This will send any Windows-style “POPUP” messages received on
# the server to the postmaster by e-mail. Not very useful, but
# an interesting demonstration of what can be accomplished.
message command = /bin/mail -s 'Message from %f on %m' postmaster < %s; rm %s &
# This is a form of caching that, when enabled, may improve
# performance when reading files.
read prediction = true
# A list of services that should be added automatically to the
# browse-list.
auto services = cdrom
# The location of your “printcap” file, a text file containing
# definitions for your printers.
printcap name = /etc/printcap
# If enabled all printers in the /etc/printcap file will be
# loaded into the browse-list.
load printers = yes
# The print command by which data is spooled to a printer under Linux.
print command = lpr -r -P%p %s
# The print command by which job queue information (printer status)
# can be obtained.
lpq command = lpq -P%p
# The print command by which unwanted print jobs can be deleted
# from the queue.
lprm command = lprm -P%p %j
# The level at which Samba advertises itself for browse elections.
# Currently set to a high value to give it an even “foot-hold” with
# any swarmy NT servers on the network. :-)
os level = 34
# These are user's personal shares. If the client's username matches on the
# server, they can access their home directory (provided they enter the
# correct password).
[homes]
# The comments appear in the browse list.
comment = Home Directories
# This matches the username of the client to that of the share.
# If they do not match, no share will be displayed in the browse
# list, or available to connect to.
user = %S
# The path to the share. For example, “smithj” would map to
# “/home/smithj”
path = /home/%S
# If enabled, allow read/write access to the shares.
writeable = yes
# Just an inverted synonym for “writeable”. We don't *really* need
# to use both. :-)
read only = no
# Keep this disabled so that a password is required to access these
# shares.
public = no
# We don't want this share (after all, it is private) to appear in
# the browse-list of other users.
browseable = no
# This is a publicly available print share, called “hp_laser”. It appears
# on the browse lists and can be accessed without a password by any client.
[hp_laser]
# The comment that appears in the browse-list.
comment = Main office printer (HP Laserjet 400)
# The username that this share is accessed as (guest means all users).
user = guest
# All generated print files will first be created in the /tmp
# directory.
path = /tmp
# Do not allow file creation except through print spooling.
writeable = no
# Set permissions accordingly -- root access to print jobs only.
create mode = 0700
# If this is enabled a password is not required to access the share.
public = yes
# This should be enabled to indicate that this is a printer share.
printable = yes
# Here is a service providing access to the CD-ROM device.
[cdrom]
comment = Shared CD-ROM drive on Linux
user = guest
path = /cdrom
writeable = no
read only = true
browseable = yes
public = yes
guest ok = yes
小技巧: 最近的 Samba 版本, 从 2.0 以後,提供了一个非常灵活以网页为基础的组态公用程式叫做``swat'',
可以使得组态过程更为友善。这个公用程式倾听伺服器上的 TCP port 901 ,所以要使用的话必须将您的浏览器
指向下面的位址:
mydomain.name:901
(当然如果要使用 SWAT 的话您需要让网页伺服器执行,像是 Apache。 查看 第7章,网页伺服器及 HTTP 快取代理
主机管理 一节 有关细节。)
最新版的 Samba 和 2.0 版之前的相比增加了很多功能。 升级到这个版本是值得的。
客户端必须有 TCP/ip network stack 以连接分享。更进一步,为了浏览工作,TCP/IP 协定必须 bound 到
NETBEUI。在 Windows 95 可以由控制台中的``网路''进行组态。
假设客端已经正常地组态好, 您应该可以看到伺服端的分享出现在“网路上的芳邻” (或如果您不是使用
Windows 95/NT的相等的方案)。您可以从网路上的芳邻对映到网路磁碟,或键入到分享的绝对路径
(例如. “\\mail\cdrom”)。 如果分享服务需要键入密码,您会被提示。
更多有关 Samba的资料可以在 Samba Home Page http://samba.anu.edu.au/samba/中找到。
- ››linux下两台服务器文件实时同步方案设计和实现
- ››Linux文件描述符中的close on exec标志位
- ››Linux下管道使用的一些限制
- ››Linux 误删/usr/bin 解决方法
- ››linux 添加新用户并赋予sudo执行权限
- ››linux常用软件安装方法
- ››Linux的分区已经被你从Windows中删除,系统启动后...
- ››linux enable命令大全
- ››Linux实现基于Loopback的NVI(NAT Virtual Interfa...
- ››Linux远程访问windows时,出现"连接被对端重...
- ››linux中使用head命令和tail命令查看文件中的指定行...
- ››linux swap 分区调控(swap分区 lvm管理)
更多精彩
赞助商链接