
mdir Command in Linux
mdir command is a part of the Mtools suite in Linux that is used to list the contents of MS-DOS directories. This command is similar to the ls command in Unix/Linux but is specifically designed for MS-DOS filesystems.
By using mdir, you can easily view files and directories on an MS-DOS disk without the need to mount it. This is particularly useful for managing files on old floppy disks or other MS-DOS formatted storage devices.
Table of Contents
Here is a comprehensive guide to the options available with the mdir command −
Syntax of mdir Command
The general syntax for using the mdir command on Linux is −
mdir [options] [msdosdrive:][path]
Where −
- mdir is the command used to list the contents of MS-DOS directories.
- [options] are various command-line options to modify how mdir behaves.
- [msdosdrive:][path] is the MS-DOS drive and path you want to list.
mdir Command Options
Here is a table summarizing the different options available for Linux mdir command −
Option | Description |
---|---|
-a | Show all entries, including hidden files. |
-b | Display a concise listing format. |
-f | Fast mode; do not read the FAT (File Allocation Table). |
/ | Directories first, then files. |
-w | Wide output format. |
Examples of mdir Command in Linux
Following are some basic examples of mdir command in Linux −
- Basic Usage
- Showing All Entries
- Recursive Listing
- Wide Output Format
- Long Listing Format
Basic Usage
To list the contents of the root directory on an MS-DOS disk, you use the mdir command followed by the drive identifier. For example −
mdir a:/
This command lists all files and directories in the root directory of the floppy drive a:. It's a simple way to see what's on the disk.
Showing All Entries
If you want to include hidden files in the listing, use the -a option. For example −
mdir -a a:/
This command lists all files, including hidden ones, in the root directory of the floppy drive a:. Hidden files are those typically not shown by default.
Recursive Listing
To list all files and directories, including subdirectories, use the -s option. For example −
mdir -s a:/
This command recursively lists all contents starting from the root directory of the floppy drive a:. It's useful for getting a complete view of all files and folders.
Wide Output Format
For a more compact display, use the -w option. For example −
mdir -w a:/
This command lists the contents in a wide format, displaying as many file names as possible in each line. It's handy for viewing many files at once.
Long Listing Format
To see detailed information about each file, similar to ls -l, use the -l option. For example −
mdir -l a:/
This command provides a long listing format, showing details like file size, date, and time. It's useful for more in-depth inspection of files.
Conclusion
The mdir is a powerful command for listing the contents of MS-DOS directories on a Linux system. By using its various options, you can effectively manage and view files on MS-DOS formatted storage media.
Mastering the mdir command enhances your ability to work with legacy systems and disks, contributing to efficient file management and system administration tasks. Whether dealing with old floppy disks or other MS-DOS devices, mdir makes the process straightforward and efficient.