Now that your smb.conf
file is correctly configured, you can start your Samba server daemon. You can do so with the /usr/sbin/smbd
command, which (with no options) starts the Samba server with all the defaults. The most common option you will change in this command is the location of the smb.conf
file; you change this option if you don't want to use the default location /etc/smb/smb.conf
. The -s option allows you to change the smb.conf
file Samba uses; this option is also useful for testing whether a new smb.conf
file actually works. Another useful option is the -l option, which specifies the log file Samba uses to store information.
To start, stop, or restart Samba from the command line, use the service
command, the system-config-services
client, or the /etc/rc.d/init.d/smb
script with a proper keyword, such as start
, like so:
# /etc/rc.d/init.d/smb start
Using the smbstatus
Command
The smbstatus
command reports on the current status of your Samba connections. The syntax is as follows:
/usr/bin/smbstatus [ options ]
Table 19.2 shows some of the available options.
TABLE 19.2 smbstatus
Options
Option |
Result |
-b |
Brief output. |
-d |
Verbose output. |
-s /path/to/config |
Used if the configuration file used at startup is not the standard one. |
-u username |
Shows the status of a specific user's connection. |
-p |
Lists current smb processes. This can be useful in scripts. |
Connecting with the smbclient
Command
The smbclient
command allows users on other Linux hosts to access your smb
shares. You cannot mount the share on your host, but you can use it in a way that is similar to that you'd use with an FTP client. Several options can be used with the smbclient
command.
The most frequently used is -I
, followed by the IP address of the computer to which you are connecting. The smbclient
command does not require root access to run:
smbclient -I 10.10.10.20 -U username%password
This gives you the following prompt:
smb:
From here, the commands are almost identical to the standard UNIX/Linux FTP commands. Note that you can omit a password on the smbclient command line. You are then prompted to enter the Samba share password.
There are two ways to mount Samba shares to your Linux host. Mounting a share is the same as mounting an available media partition or remote NFS directory, except that you use SMB to access the Samba share. (See Chapter 35, "Managing the File System," to see how to mount partitions.) The first method uses the standard Linux mount
command:
mount -t smbfs //10.10.10.20/homes /mount/point -o username=ahudson,dmask=777,\
fmask=777
NOTE You can substitute a hostname for an IP address if your name service is running or the host is in your /etc/hosts
file.
This command mounts ahudson
's home directory on your host and gives all users full permissions to the mount. The permissions are equal to the permissions on the chmod
command.
The second method produces the same results, using the smbmount
command as follows:
# smbmount //10.10.10.20/homes /mount/point -o username=ahudson,dmask-777,\
fmask=777
To unmount the share, use the standard:
# umount /mount/point
These mount
commands can also be used to mount true Windows client shares to your Fedora host. Using Samba, you can configure your server to provide any service Windows can serve, and no one but you will ever know.
Network and Remote Printing with Fedora
Chapter 8, "Printing with Fedora," discussed how to set up and configure local printers and the associated print services. This section covers configuring printers for sharing and access across a network.
Offices all over the world benefit from using print servers and shared printers. In my office, I have two printers connected to the network via a Mac mini with Fedora PPC so that my wife can print from downstairs through her a wireless link, and I can print from my three computers in my office. It is a simple thing to do and can bring real productivity benefits, even in small settings.
Setting up remote printing service involves configuring a print server and then creating a remote printer entry on one or more computers on your network. This section introduces a quick method of enabling printing from one Linux workstation to another Linux computer on a LAN. You also learn about SMB printing using Samba and its utilities. Finally, this section discusses how to configure network-attached printers and use them to print single or multiple documents.
Enabling Network Printing on a LAN
To set up printing from one Linux workstation to another across a LAN, you need root permission and access to both computers, but the process is simple and easy to perform.
First, log in or ssh
to the computer to which the printer is attached. This computer is the printer server. Use the hostname
or ifconfig
commands to obtain the hostname or IP address and write down or note the name of the printer queue. If the system uses LPRng rather than CUPS (Common UNIX Printing System) , you need to edit the file named /etc/lpd.perms
. Scroll to the end of the file and look for the remote permission entry:
# allow local job submissions only
REJECT SERVICE=X NOT SERVER
Remote printing is not enabled by default, so you must comment out the service reject line with a pound sign ( #
):
# allow local job submissions only
#REJECT SERVICE=X NOT SERVER
Save the file, and then restart the lpd
daemon.
This enables incoming print requests with the proper queue name (name of the local printer) from any remote host to be routed to the printer. After you finish, log out and go to a remote computer on your LAN without an attached printer.
TIP
LPRng, like CUPS, can be configured to restrict print services to single hosts, one or more specific local or remote users, all or part of a domain, or a LAN segment (if you specify an IP address range). An entry in /etc/lpd.perms
, for example, to allow print requests only from hosts on 192.168.2.0
, would look like this:
ACCEPT SERVICE=X REMOTEIP=192.168.2.0/255.255.255.0
The lpd.perms
man page (included as part of the LPRng documentation) contains an index of keywords you can use to craft custom permissions. Don't forget to restart the lpd daemon after making any changes to /etc/lpd.perms
(or /etc/lpd.conf
).
If the computer with an attached printer is using Fedora and you want to set up the system for print serving, again use the system-config-printer
client. You can create a new printer, but the easiest approach is to publish details of your printer across the network.
Читать дальше