LinuxCommandLibrary

mdir

Display MS-DOS directory contents

SYNOPSIS

mdir [options] [msdos_path ...]
mdir [options] drive:
mdir [options] device:
mdir [options] device::

PARAMETERS

-a
    Display all files, including hidden and system files.

-b
    Bare format: lists only file and directory names, one per line.

-D
    Device-specific output: treats the argument as a device name rather than a path, for example, mdir -D /dev/fd0.

-L
    Lowercase names: displays filenames in lowercase.

-r
    Recursive listing: lists subdirectories recursively.

-s
    Short format: displays filename, size, and modification date/time in a compact format.

-t
    Terse format: similar to short, but even more compact, omitting file sizes.

-w
    Wide format: displays filenames across the screen in multiple columns.

-X
    Display extended attributes: shows additional attributes like archive, read-only, hidden, system alongside the filename.

-x
    Short names only: displays only the 8.3 short filenames, ignoring long filenames.

-V
    Verbose output: prints additional information about the command's operation, such as device access.

-G
    Do not group directories: By default, directories are listed first, followed by files. This option disables that grouping.

-/
    Use forward slashes: interprets '/' as a path separator instead of the default ''.

DESCRIPTION

The mdir command is a utility from the mtools package, designed to list the contents of directories on MS-DOS filesystems. It functions similarly to the standard Unix ls command, but specifically for FAT-formatted media such as floppy disks, hard disk images, or partitions. mdir allows Linux and Unix users to inspect the directory structure, file names, sizes, and modification dates of files stored on DOS-compatible volumes without needing to mount them. This is particularly useful for quick inspections, troubleshooting, or interacting with legacy data. It provides various formatting options to display information concisely or with more detail, mimicking different output styles found in DOS's own DIR command.

CAVEATS

mdir is part of the mtools package and requires it to be installed. It primarily operates on MS-DOS/FAT filesystems and may not fully support more modern filesystem features or permissions found in Unix-like systems. While it can read VFAT (long filenames), some output modes might default to displaying only the 8.3 short filenames. It does not modify the filesystem; it is a read-only directory listing tool. Ensure the correct device or image path is specified, as incorrect usage might lead to "No such file or directory" errors even if the device exists.

CONFIGURATION

mdir's behavior can be influenced by the mtools configuration file, typically /etc/mtools.conf or ~/.mtoolsrc. This file defines drive letters, device mappings, and default settings, allowing users to customize how mdir interacts with different FAT volumes. For example, drive a: or drive b: can be mapped to specific floppy devices, or drive c: to a hard disk partition.

MS-DOS PATH SYNTAX

When specifying msdos_path, mdir by default expects DOS-style path separators (backslashes, \). However, using the -/ option allows you to use forward slashes (/) which is more common in Unix environments. Paths can include drive letters (e.g., a:\mydata\) or refer to the current working directory on the DOS volume.

HISTORY

The mtools package, which includes mdir, originated in the early days of Linux and Unix systems to provide compatibility with MS-DOS filesystems. As DOS was a prevalent operating system, tools were needed to easily access and manage data on DOS-formatted floppy disks and partitions without requiring a full DOS emulation or a reboot. mdir, along with other mtools commands, filled this gap by providing a familiar command-line interface for DOS filesystem operations. Its development has continued to adapt to various FAT filesystem extensions, such as VFAT (long filenames), maintaining its utility for accessing legacy and cross-platform data.

SEE ALSO

ls(1), mtools(1), mcopy(1), mdel(1), mmd(1), mrd(1), mcd(1), mlabel(1)

Copied to clipboard