The following options apply to all of the mtools commands:
-o | Overwrite primary names by default. |
-O | Overwrite secondary names by default. |
-r | Rename primary name by default. |
-R | Rename secondary name by default. |
-a | Autorename primary name by default. |
-A | Autorename secondary name by default. |
-s | Skip primary name by default. |
-S | Skip secondary name by default. |
-m | Ask user what to do with primary name. |
-M | Ask user what to do with secondary name. |
mattrib
[-a|+a] [-h|+h] [-r|+r] [-s|+s] [-/] [-X] MSDOSFILE [ MSDOSFILES ]
This command is used to add or remove attribute flags on an MS-DOS file.
Example: To make the MS-DOS file "secret.txt" on the floppy disk invisible to the dos dir command, use
mattrib +h secret.txt
a | Add archive bit. |
r | Indicates a read-only file. |
s | Indicates an operating system file. |
h | If set, this bit makes file hidden from the DIR command. |
/ | Displays recursive listing of attributes in subdirectories. |
X | Displays attributes without padding with white space. |
mbadblocks DRIVE:
Scans an MS-DOS disk for bad blocks.
Example: To scan the floppy disk in the drive for bad blocks, use
mbadblocks
mcd
[MSDOSDIRECTORY]
If invoked with no arguments, this command displays the current working directory. If invoked with arguments, it changes the current working directory as specified.
Example: To change to the subdirectory "examples" on the floppy disk, use
mcd examples
mcopy
[-b/ptnvmoQOsSrRA] SOURCEFILE TARGETFILE
mcopy
[-b/ptnvmoQOsSrRA] SOURCEFILE [ SOURCEFILES ] TARGETDIRECTORY
mcopy
[-tnvm] MSDOSSOURCEFILE
This command copies files as specified from source to destination. The source and target may be either MS-DOS or Linux files.
Example: To copy the Linux file /etc/hosts to the MS-DOS formatted floppy disk in /dev/fd0 (also known as the A: drive), use
mcopy /etc/hosts A:
b | Optimize operation for large recursive copies. |
/ | Invoke recursive copy. |
p | Preserve attributes of copied files. |
Q | When mcopying multiple files, tell mcopy to quit as soon as a copy fails. |
t | Invoke text file transfer. |
n | Tell mcopy to overwrite UNIX files without prompting. |
m | Retain file modification time. |
mdel
[-v] MSDOSFILE [ MSDOSFILES ]
Delete a file from an MS-DOS filesystem. This command will prompt before deleting a read-only file.
Example: To delete the file "test" from the floppy disk in the A: drive, use
mdel A:\test
mdeltree
[-v] MSDOSDIRECTORY [MSDOSDIRECTORIES ]
This command is used to remove a directory and all the files and subdirectories contained therein.
Example: To remove the entire subdirectory tree rooted at examples, use
mdeltree examples
mdir
[-/] [-f] [-w] [-a] [-X] MSDOSFILE [ MSDOSFILES ]
This command is used to display the contents of an MS-DOS directory.
Example: To display the contents of the directory examples on the floppy disk, use
mdir
/ | Invokes recursive output. |
w | List filenames across the display with no other information (wide output). |
a | Include hidden files in the list. |
f | Specify fastest possible operation. |
X | Invoke concise listing. |
mdu
[-a] [ MSDOSFILES ]
List the space used by a directory, including its subdirectories and files.
Example: To display the space used by the subdirectory examples on the floppy disk in the A: drive, use
mdu
a | Include all files. |
s | Summary information only. |
mformat
[-t CYLINDERS] [-h HEADS] [-s SECTORS] [-l VOLUME_LABEL] [-F] [-I FSVERSION] [-S SIZECODE] [-2 SECTORS_ON_TRACK_0] [-M SOFTWARE_SECTOR_SIZE] [-a] [-X] [-C] [-H HIDDEN_SECTORS] [-r ROOT_SECTORS] [-B BOOT_SECTOR] [-0 RATE_ON_TRACK_0] [-A RATE_ON_OTHER_TRACKS] [-1] [-k] DRIVE:
Format a diskette with a minimal filesystem (boot sector, FAT, root directory).
Examples: To format the floppy disk in the A: drive for use by MS-DOS, type
mformat
I have no particular reason to be suspicious of the mformat command, but I think that, in general, it's best to let each operating system format it's own disk space. You might want to consider using the mformat command as a backup, to be used only when there are no DOS/Windows machines around. |
t | Specify the number of cylinders. |
h | Specify the number of heads (sides). |
s | Specify the number of sectors per track. |
l | Specify volume label. |
S | Specify sizecode. |
2 | Force 2m format. |
1 | Do not use 2m format. |
M | Specify software sector size. |
a | Force generation of an Atari-style serial number. |
X | Format disk as an XDF disk. |
C | Create the disk image file to install the MS-DOS filesystem on it. (Obviously, this is useless on physical devices such as floppies and hard disk partitions.) |
H | Specify number of hidden sectors. |
n | Display serial number. |
F | Format the partition as FAT32 (experimental). |
I | Set the fsVersion id when formatting a FAT32 drive. |
c | Specify size of a cluster (in sectors). |
r | Set the size of the root directory (in sectors). |
B | Use bootsector stored in the file or device. |
k | As much as possible, keep the existing boot sector. |
0 | Display data transfer rate on track 0. |
A | Display data transfer rate on tracks other than 0. |
mlabel
[-vcs] DRIVE:[NEW_LABEL]
Adds a volume label to a disk. If no label is specified, it will prompt the user to enter one. (Volume labels show up in mdir listings.)
Example: To label the disk in the current drive "Linux_Ports", use
mlabel A:Linux_Ports
c | Clear the existing label. |
s | Show the existing label. |
mmd
[-voOsSrRA] MSDOSDIRECTORY [ MSDOSDIRECTORIES ]
Creates the specified directory on an MS-DOS filesystem.
Example: To create the subdirectory "examples" on the disk in the floppy drive, type
mmd examples
mrd
[-v] MSDOSDIRECTORY [DOSDIRECTORIES ]
Deletes a subdirectory from an MS-DOS file system.
Example: To remove the subdirectory "examples" from the disk in the floppy drive, type
mrd examples
mmove
[-voOsSrRA] SOURCEFILE TARGETFILE
mmove
[-voOsSrRA] SOURCEFILE [ SOURCEFILES ] TARGETDIRECTORY
Renames an existing MS-DOS file or subdirectory.
Example: To move the file "smbstuff" into the directory "examples" from the root directory of the floppy drive, type
mmove smbstuff examples
mtype
[-ts] MSDOSFILE [ MSDOSFILES ]
Displays contents of an MS-DOS file to the screen.
Example: To display the contents of the file "smbstuff.txt" to the screen, type
mtype smbstuff.txt
t | Optimize for text file viewing. |
s | Strip high bit from the data. |
xcopy
source_dir target_dir
Recursively copies one directory to another.
Example: To recursively copy the contents of the subdirectory "examples" to the subdirectory "text", type
xcopy examples text
nmbd
[ -D ] [ -H netbios hosts file ] [ -d debuglevel ] [ -l log basename ] [ -n netbios name ] [ -p port number ] [ -s configuration file ]
The nmbd daemon is the part of the samba suite that handles netbios name-server requests. It also has the capability of working as a Windows Internet Name Server (WINS).
Example: Inetd (see the chapter on daemons) can be used to start nmbd and smbd, as appropriate. To do so, include the following entries in the /etc/services file:
netbios-ssn 139/tcp
netbios-ns 137/udp
These two entries associate the netbios-ssn service with port 139 and the netbios-ns service with port 137. Once the association has been made, inetd can monitor ports 137 and 139 for requests. Upon receiving a request, inetd will look in the inetd.conf file for instructions on how to handle it. You will need to add the following lines to the inetd.conf file to tell it how:
netbios-ssn stream tcp nowait root /usr/sbin/smbd smbd
netbios-ns dgram upd wait root /usr/sbin/nmbd nmbd
When configuring samba on NFS machines, remember that you must modify the /etc/services file on the NIS master. |
-B | This option is obsolete. It is included for backward compliance. |
-I | This option is obsolete. It is replaced by the interfaces option in smb.conf. |
-D | This option tells the server to operate as a daemon. |
-Ccomment string | This option has been replaced by the "server string" option in smb.conf. |
-G | This option has been replaced by the "workgroup" option in smb.conf. |
-Hnetbios hosts file | This option allows the command line specification of a file containing a list of netbios names, which the server is allowed to reply to. The file is formatted as follows: [IP address | hostname][netbios name] |
-N | This option has been replaced by the "interfaces" option in smb.conf. |
-ddebuglevel | This option specifies the debug level. |
-llogfile | This option specifies a path and base filename for storing login information. |
-nnetbios_name | This option specifies a netbios name other than the default. |
-a | This option appends to log files, rather than overwrite. |
-pport number | This option specifies the port number. |
-sconfiguration file | This option specifies a default configuration file other than /etc/samba.conf. |
smbclient servicename
[ password ] [ -E ] [ -L host ] [ -M host ] [ -I IP number ] [ -R name resolve order ] [ -N ] [ -P ] [ -U username ] [ -d debuglevel ] [ -l log basename ] [ -n netbios name ] [ -W workgroup ] [ -O socket options ] [ -p port number ] [ -c command string ] [ -T tar options ] [ -D initial directory ]
smbclient is a client program designed to communicate with a Lan Manager server. Its functionality is not unlike ftp in that it is mostly used for the getting and putting of files and directory information. It can also be used as an interface to other server resources (e.g., printers).
Example: To use smbclient to print the file test.txt to the printer HPLJ6 on the server Loki, type
smbclient "\\Loki\HPLJ6" password -U guest -c "translate; print test.txt"
This command assumes a valid guest account, and the password is in plain text. Also, observe the use of the translate command before the print command, which translates the file to be printed from Linux format to something more palatable to Windows machines. |
Example: The following example shows how I used smbclient to retrieve the file "test" from the "E:" drive on the machine Loki. Commands that I actually typed are in boldface, the machine responses are in regular text:
[shawkins@odin shawkins]$ smbclient '\\Loki\e'
Server time is Sun Aug 1 14:16:50 1999
Timezone is UTC-4.0
Password:
security=share
smb: \> get test.txt localtest.txt
getting file \test.txt of size 30 bytes
as localtest.txt (3.66206 kb/s) (average 3.66211
kb/s)
smb: \> quit
You will need to quote your backslashes when typing UNC names within a Linux shell (e.g., "\\Loki\HPLJ6" rather than \\Loki\HPLJ6). Slashes will also work on Samba versions greater than 1.9.17. (e.g., //Loki/HPLJ6). |
servicename | Name of the server service that you wish to access. Service names are in the UNC format; \\server\service, where server is the netbios name of the server and service is any service that is offered (e.g., a particular printer, <some other shared resource>). Note that the netbios name of the server may be distinct from the host name of the same server. |
password | Allows the user to specify a password for the service that it is attempting to access. |
-Rname_resolve_order | Specifies a method for name resolution. If used, it overrides the default value specified as the "name resolve order" of smb.conf. |
-L | Lists the services available on the specified server. |
-M | Sends messages via the WinPopup protocol. After a connection is established, type your message, terminating with ^D (Control + D). (Note that if the target computer is not running WinPopup, your message will disappear without any error messages.) |
-E | Tells smbclient to send any error messages to standard error, rather than standard output. |
-IIP number | Specifies an IP number of the server to which you wish to connect. |
-N | Suppresses the normal password prompt. |
-Osocket options | Sees the socket options section of smb.conf for details. |
-P | Specifies that the service smbclient is connecting to is a printer service. |
-Uusername | Specifies a username for use in accessing services. |
-ddebuglevel | Specifies a debug level from 0 (less detail) to 5 (more detail). |
-lbasename | Specifies a nondefault base file name to which logging messages are sent. |
-nnetbios name | Specifies a name, other than the (all-uppercase) hostname of the current machine, as the netbios name. |
-Wworkgroup | Specifies a workgroup to be used for the connection. |
-pport number | Specifies a port number used for making connections to the server. Overrides the default of 139. |
-T <c|x>[IXbgNa] | This is a tar operation. The aforementioned options correspond to the following actions: |
c | Create a tar file. |
x | Restore a local tar file back to a share. |
I | Include the specified files and directories (default behavior). |
X | Exclude the specified files and directories. |
b | Blocksize. |
g | Tell tar to back up only those files with the archive bit set (Incremental). |
N | Invoke newer than <specified file>. |
a | Reset the archive bit once the file is backed up. |
-Dinitial directory | Tells smbclient to switch to the specified directory before starting. |
-ccommandstring | Executes the specified list of commands, rather than prompting. Commandstring is delimited by colons. |
Smbclient is interactive. The following commands are valid at the smb command prompt ("smb: <current directory>>").
?[command], help[command] | Invoke Help. (Either prints information on the specified command or, if none specified, on all available commands.) | |
![shell command] | Run the specified shell command on the local machine. | |
cd[directory] | Change to the specified directory. | |
del<mask> | Delete all files, matching the specified mask. | |
dir<mask>,ls<mask> | List all files in the current directory, matching the specified mask. | |
exit, quit | Close connection and exit. | |
get<remote file name> [local file name] | Copy file from the server to the local machine. | |
lcd[directory name] | Change directories on the local machine. | |
lowercase | Toggle the conversion of filenames to lowercase letters. | |
mask | Specify a mask for use during recursive use of the mget and mput commands. Masks consist of a label and the pattern to be used in place of that label (e.g., source *.c). | |
mget<mask> | Copy all files matching the specified mask from the server to the client. | |
mkdir<directory name>, md<directory name> | Create a new directory on the server. | |
mput<mask> | Copy all files matching the specified mask from the client to the server. | |
print<file name> | Print the specified file from the local machine through a printable service on the server. | |
printmode<graphics or text> | Toggle the print mode between graphics and text. | |
prompt | Toggle prompting for filenames when executing mget and mput commands. | |
put<local file name> [remote file name] | Copy the local file from the client to the server. | |
queue | Display print queue information. | |
recurse | Toggle recursion on/off of the mget and mput commands. | |
rm | Delete all files matching the specified mask from the server. | |
rmdir<directory name>, rd<directory name> | Attempt to remove the specified directory from the server. | |
tar <c|x>[IXbgNa] | Perform one of the following tar operations: | |
c | Create a tar file. | |
x | Restore a local tar file back to a share. | |
I | Include the specified files and directories (default behavior). | |
X | Exclude the specified files and directories. | |
b | Blocksize. | |
g | Tell tar to back up only those files with the archive bit set (Incremental). | |
N | Invoke newer than <specified file>. | |
a | Reset the archive bit once the file is backed up. | |
blocksize | Specify a blocksize in multiples of 512 bytes. |
smbmount
servicename mount-point [ -h ] [ -C ] [ -n ] [ -P password ] [ -s server name ] [ -c client name ] [ -I hostname/IP ] [ -U user name ] [ -D domain name ] [ -u uid ] [ -g gid ] [ -f file mode ] [ -d dir mode][-m max xmit ] [ -p port ]
This program enables you to mount an SMB filesystem on a Linux machine.
Example: To mount the e directory of the Win-95 machine "Loki" at the /mnt/loki directory of the Linux machine odin, use
smbmount //Loki/e /mnt/loki |
In order to do this, you first have to set up the directory as a share on the Win-95 machine. Create a directory, right click on it, choose the Properties menu item, then choose the Sharing tab, and specify what kind of access you want. |
servicename | This option specifies the service you want to use on the server. Format is //server/service/rootdir. |
mount-point | This option specifies the directory over which you wish to mount the filesystem. |
-h | This option displays help information. |
-C | This option tells smbmount not to convert does not passwords to uppercase. |
-n | This option is used when mounting shares that do not require a password. |
-Ppassword | This argument allows the user to specify the password on the command line. |
-snetbios_server_name | This argument enables specification of netbios server name when it is distinct from the servername. |
-cnetbios_client_name | Use this option to enable specification of netbios client name when it is distinct from the servername. |
-Ihostname/IP of the server | This option specifies hostname or IP address of the server when distinct from netbios name. |
-Uuser name | This option is used to specify Lan Manager side user name if distinct from Linux user name. |
-Ddomain name | This option is used to specify domain name at login time. |
-uuid, -ggid | This option enables command line specification of user and group ids (default = current user). |
-ffile mode, -ddir mode | This option specifies file and directory modes for mounted filesystems. |
-pport | This option specifies TCP port to connect to on the server (default = 139). |
-mmax xmit | This option specifies the maximum packet size to be transmitted. |
smbd
[ -D ] [ -a ] [ -d debuglevel ] [ -l log file ] [ -p port number ] [ -O socket options] [ -s configuration file ]
This program is a server that provides SMB (a.k.a. Lan Manager) services to clients. Clients include MSCLIENT 3.0, Windows for Workgroups, Windows 95, Windows NT, OS2, DAVE for Macintosh, and smbfs for Linux.
The configuration file (smb.conf) is automatically reloaded every minute.
Example: Inetd (see the chapter on daemons) can be used to start nmbd and smbd, as appropriate. To do so, include the following entries in the /etc/services file:
netbios-ssn 139/tcp
netbios-ns 137/udp
These entries associate the netbios-ssn service with port 139 and the netbios-ns service with port 137. Once the association has been made, inetd can monitor ports 137 and 139 for requests. Upon receiving a request, inetd will look in the inetd.conf file for instructions on how to handle it. You will need to add the following lines to the inetd.conf file to tell it how:
netbios-ssn stream tcp nowait root /usr/local/samba/bin/smbd smbd
netbios-ns dgram upd wait root /usr/local/samba/bin/nmbd nmbd
-D | Tell the server to run as a daemon. |
-a | Tell smbd to overwrite log files with each new connection, rather than append. |
-ddebuglevel | Specify level of detail (0-10) for debugging output. Detail of output increases with debug level. |
-llog file | Specify a base filename into which operational data will be logged. |
-pport number | Specify a port number other than the default of 139. |
-sconfiguration file | Specify a file containing configuration information other than the default. |
smbumount
mount-point
This command unmounts a smb filesystem.
Example: To unmount the smb directory mounted in the smbmount example, use
smbumount /mnt/loki |
mount-point | mount-point is the directory you want to unmount. |
smbstatus
[ -b ] [ -d ] [ -p ] [ -s configuration file ]
This program is used to display status information on current samba connections.
Example: To display status information on current samba connections, use
smbstatus
-b | Invoke brief output. |
-d | Invoke verbose output. |
-p | Display a list of smbd processes and exit. |
-s configuration file | Specify a configuration file other than the default. |
testparm
[ configfilename [ hostname hostIP ] ]
This command is used to test the smbd configuration file for internal correctness.
Example: There really aren't that many options on this command, just use
testparm
configfilename | Specify the configuration file to be checked. |
hostname | Check host access of the specified machine. (Use in conjunction with the hostIP address.) |
hostIP | Specify the IP address of a previously specified hostname. |