FreeDOS 的简单介绍
FreeDOS DOS

> 
> 学习如何穿行于 C:\ 提示符下，就像上世纪 90 年代的 DOS 高手一样。
> 
> 
> 


![](/data/attachment/album/201809/05/203949lr4q42rc6e4pp9s2.png)


FreeDOS 是一个古老的操作系统，但是对于多数人而言它又是陌生的。在 1994 年，我和几个开发者一起 [开发了 FreeDOS](https://opensource.com/article/17/10/freedos) —— 这是一个完整、自由、兼容 DOS 的操作系统，你可以用它来玩经典的 DOS 游戏、运行过时的商业软件或者开发嵌入式系统。任何在 MS-DOS 下工作的程序在 FreeDOS 下也可以运行。


在 1994 年，任何一个曾经使用过微软的商业版 MS-DOS 的人都会迅速地熟悉 FreeDOS。这是设计而为之的；FreeDOS 尽可能地去模仿 MS-DOS。结果，1990 年代的 DOS 用户能够直接转换到 FreeDOS。但是，时代变了。今天，开源的开发者们对于 Linux 命令行更熟悉，或者他们可能倾向于像 [GNOME](https://opensource.com/article/17/8/gnome-20-anniversary) 一样的图形桌面环境，这导致 FreeDOS 命令行界面最初看起来像个异类。


新的用户通常会问，“我已经安装了 [FreeDOS](http://www.freedos.org/)，但是如何使用呢？”。如果你之前并没有使用过 DOS，那么闪烁的 `C:\>` DOS 提示符看起来会有点不太友好，而且可能有点吓人。这份 FreeDOS 的简单介绍将带你起步。它只提供了基础：如何浏览以及如何查看文件。如果你想了解比这里提及的更多的知识，访问 [FreeDOS 维基](http://wiki.freedos.org/)。


### DOS 提示符


首先，让我们看一下空的提示符以及它的含义。


![](/data/attachment/album/201809/05/203950cfvvkj2y6f61ryi6.png)


DOS 是在个人电脑从软盘运行时期创建的一个“<ruby> 磁盘操作系统 <rt>  disk operating system </rt></ruby>”。甚至当电脑支持硬盘了，在 1980 年代和 1990 年代，频繁地在不同的驱动器之间切换也是很普遍的。举例来说，你可能想将最重要的文件都备份一份拷贝到软盘中。


DOS 使用一个字母来指代每个驱动器。早期的电脑仅拥有两个软盘驱动器，他们被分配了 `A:` 和 `B:` 盘符。硬盘上的第一个分区盘符是 `C:` ，然后其它的盘符依次这样分配下去。提示符中的 `C:` 表示你正在使用第一个硬盘的第一个分区。


从 1983 年的 PC-DOS 2.0 开始，DOS 也支持目录和子目录，非常类似 Linux 文件系统中的目录和子目录。但是跟 Linux 不一样的是，DOS 目录名由 `\` 分隔而不是 `/`。将这个与驱动器字母合起来看，提示符中的 `C:\` 表示你正在 `C:` 盘的顶端或者“根”目录。


`>` 符号是提示你输入 DOS 命令的地方，就像众多 Linux shell 的 `$`。`>` 前面的部分告诉你当前的工作目录，然后你在 `>` 提示符这输入命令。


### 在 DOS 中找到你的使用方式


在 DOS 中浏览目录的基本方式和你在 Linux 命令行下的步骤非常相似。你仅需要记住少数的命令。


#### 显示一个目录


当你想要查看当前目录的内容时，使用 `DIR` 命令。因为 DOS 命令是大小写不敏感的，你也可以输入 `dir`。默认地，DOS 会显示每个文件和子目录的细节，包括了名字、扩展类型、大小以及最后一次更改的日期和时间。


![](/data/attachment/album/201809/05/203951vemv29avkbcb3fob.png)


如果你不想显示单个文件大小的额外细节，你可以在 `DIR` 命令中使用 `/w` 选项来显示一个“宽”的目录列表。注意，Linux 用户使用连字号（`-`）或者双连字号（`--`）来开始命令行选项，而 DOS 使用斜线字符（`/`）。


![](/data/attachment/album/201809/05/203952dddc5t2q9kkf2kfx.png)


你可以将特定子目录的路径名作为参数传递给 `DIR` 命令来查看它。此外，另一个与 Linux 系统的区别是 Linux 文件和目录是大小写敏感的，而 DOS 下的名称是大小写不敏感的。DOS 通常将文件和目录使用全部大写的方式显示，不过你可以等同地用小写格式来使用它们。


![](/data/attachment/album/201809/05/203953h888oofyocwi7f4w.png)


#### 切换当前工作目录


一旦你能够查看一个目录的内容，你就能够“移动到”任何其它的目录。在 DOS 上，使用 `CHDIR` 命令来切换工作目录，也可以简写为 `CD`。你可以使用类似 `CD CHOICE` 的命令进入到一个子目录或者使用 `CD \FDOS\DOC\CHOICE` 进入到一个新的路径。


![](/data/attachment/album/201809/05/203954o3q3ob0sgoqseeng.png)


就像在 Linux 命令行，DOS 使用 `.` 来表示当前目录，而 `..` 表示父目录（当前目录的上一级）。你可以将这些组合起来使用。比如，`CD ..` 进入到父目录，然后 `CD ..\..` 由当前目录做两个“向上”目录级别的操作。


![](/data/attachment/album/201809/05/203955zl7sia51pc3s73pt.png)


FreeDOS 也从 Linux 那借鉴了一些特性：你可以使用 `CD -` 跳转回之前的工作目录。在你进入一个新的路径做完一件事之后，想要回退到之前工作状态的情况下，这会很方便。


#### 切换当前工作盘符


在 Linux 下，“磁盘”的概念是隐藏的。在 Linux 和其它 Unix 系统中，你“挂载”磁盘到一个目录，例如 `/backup`，或者系统自动帮你完成，比如 `/var/run/media/user/flashdrive`。但是 DOS 是一个相对简单的系统。使用 DOS，你必须自行更改工作磁盘。


记住 DOS 分配第一块硬盘的第一个分区为 `C:` 盘，然后这样依次分配其它盘符。在现代系统中，人们很少将硬盘分割成多个 DOS 分区；他们简单地使用整个磁盘或者尽可能多地分配给 DOS。如今 `C:` 通常是第一块硬盘，而 `D:` 通常是另一块硬盘或者 CD-ROM 驱动器。其它的网络磁盘驱动器也可以被映射到别的盘符，比如 `E:` 或者 `Z:` 或者任何你想要的组织方式。


在 DOS 下切换磁盘很容易。只要在命令行输入盘符后附加一个冒号（`:`），然后 DOS 就会切换到该工作磁盘。举例来说，在我的 [QEMU](https://www.qemu.org/) 系统上，我将 `D:` 设置到我的 Linux 主目录下的一个共享目录，那里存放了各种我想测试的 DOS 应用程序和游戏的安装文件。


![](/data/attachment/album/201809/05/203959mk8y7w874tm9r22v.png)


小心不要尝试切换到一个不存在的磁盘。DOS 可能会将它设置为工作磁盘，但是如果你尝试在那做任何事，你将会遇到略微臭名昭著的“<ruby> 退出、重试、失败 <rt>  Abort, Retry, Fail </rt></ruby>” DOS 错误信息。


![](/data/attachment/album/201809/05/203959cj6usj1umspsj76l.png)


### 其它可以尝试的事情


使用 `CD` 和 `DIR` 命令，你就拥有了基础的浏览 DOS 能力。这些命令允许你查找 DOS 目录并查看其他子目录和文件的存在。一旦你熟悉基础浏览操作，你还可以尝试其它的这些基础 DOS 命令：


* `MKDIR` 或 `MD` 创建新的目录
* `RMDIR` 或 `RD` 删除目录
* `TREE` 以树状格式显示目录和子目录列表
* `TYPE` 和 `MORE` 显示文件内容
* `RENAME` 或 `REN` 重命名文件
* `DEL` 或 `ERASE` 删除文件
* `EDIT` 编辑文件
* `CLS` 清除屏幕


如果这些还不够，你可以在 FreeDOS 维基上面找到[所有 DOS 命令](http://wiki.freedos.org/wiki/index.php/Dos_commands)的清单。


在 FreeDOS 下，针对每个命令你都能够使用 `/?` 参数来获取简要的说明。举例来说，`EDIT /?` 会告诉你编辑器的用法和选项。或者你可以输入 `HELP` 来使用交互式帮助系统。


像任何一个 DOS 一样，FreeDOS 被认为是一个简单的操作系统。仅使用一些基本命令就可以轻松浏览 DOS 文件系统。那么，启动一个 QEMU 会话，安装 FreeDOS，然后尝试一下 DOS 命令行界面吧。也许它现在看起来就没那么吓人了。




---


via: <https://opensource.com/article/18/4/gentle-introduction-freedos>


作者：[Jim Hall](https://opensource.com/users/jim-hall) 选题：[lujun9972](https://github.com/lujun9972) 译者：[icecoobe](https://github.com/icecoobe) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
FreeDOS is an old operating system, but it is new to many people. In 1994, several developers and I came together to [create FreeDOS](https://opensource.com/article/17/10/freedos)—a complete, free, DOS-compatible operating system you can use to play classic DOS games, run legacy business software, or develop embedded systems. Any program that works on MS-DOS should also run on FreeDOS.


In 1994, FreeDOS was immediately familiar to anyone who had used Microsoft's proprietary MS-DOS. And that was by design; FreeDOS intended to mimic MS-DOS as much as possible. As a result, DOS users in the 1990s were able to jump right into FreeDOS. But times have changed. Today, open source developers are more familiar with the Linux command line or they may prefer a graphical desktop like [GNOME](https://opensource.com/article/17/8/gnome-20-anniversary), making the FreeDOS command line seem alien at first.

New users often ask, "I [installed FreeDOS](http://www.freedos.org/), but how do I use it?" If you haven't used DOS before, the blinking `C:\>`

DOS prompt can seem a little unfriendly. And maybe scary. This gentle introduction to FreeDOS should get you started. It offers just the basics: how to get around and how to look at files. If you want to learn more than what's offered here, visit the [FreeDOS wiki](http://wiki.freedos.org/).

## The DOS prompt

First, let's look at the empty prompt and what it means.

![The empty DOS prompt](https://opensource.com/sites/default/files/u128651/0-prompt.png)

opensource.com

DOS is a "disk operating system" created when personal computers ran from floppy disks. Even when computers supported hard drives, it was common in the 1980s and 1990s to switch frequently between the different drives. For example, you might make a backup copy of your most important files to a floppy disk.

DOS referenced each drive by a letter. Early PCs could have only two floppy drives, which were assigned as the `A:`

and `B:`

drives. The first partition on the first hard drive was the `C:`

drive, and so on for other drives. The `C:`

in the prompt means you are using the first partition on the first hard drive.

Starting with PC-DOS 2.0 in 1983, DOS also supported directories and subdirectories, much like the directories and subdirectories on Linux filesystems. But unlike Linux, DOS directory names are delimited by `\`

instead of `/`

. Putting that together with the drive letter, the `C:\`

in the prompt means you are in the top, or "root," directory of the `C:`

drive.

The `>`

is the literal prompt where you type your DOS commands, like the `$`

prompt on many Linux shells. The part before the `>`

tells you the current working directory, and you type commands at the `>`

prompt.

## Finding your way around in DOS

The basics of navigating through directories in DOS are very similar to the steps you'd use on the Linux command line. You need to remember only a few commands.

### Displaying a directory

When you want to see the contents of the current directory, use the `DIR`

command. Since DOS commands are not case-sensitive, you could also type `dir`

. By default, DOS displays the details of every file and subdirectory, including the name, extension, size, and last modified date and time.

![Displaying a directory with DIR](https://opensource.com/sites/default/files/u128651/1-dir.png)

opensource.com

If you don't want the extra details about individual file sizes, you can display a "wide" directory by using the `/w`

option with the `DIR`

command. Note that Linux uses the hyphen (`-`

) or double-hyphen (`--`

) to start command-line options, but DOS uses the slash character (`/`

).

![Displaying a wide directory with DIR /w](https://opensource.com/sites/default/files/u128651/2-dirw.png)

opensource.com

You can look inside a specific subdirectory by passing the pathname as a parameter to `DIR`

. Again, another difference from Linux is that Linux files and directories are case-sensitive, but DOS names are case-insensitive. DOS will usually display files and directories in all uppercase, but you can equally reference them in lowercase.

![Displaying the contents of the FDOS directory](https://opensource.com/sites/default/files/u128651/3-dir-fdos.png)

opensource.com

### Changing the working directory

Once you can see the contents of a directory, you can "move into" any other directory. On DOS, you change your working directory with the `CHDIR`

command, also abbreviated as `CD`

. You can change into a subdirectory with a command like `CD CHOICE`

or into a new path with `CD \FDOS\DOC\CHOICE`

.

![Changing into the \FDOS\DOC\CHOICE subdirectory](https://opensource.com/sites/default/files/u128651/5-dir-choice.png)

opensource.com

Just like on the Linux command line, DOS uses `.`

to represent the current directory, and `..`

for the parent directory (one level "up" from the current directory). You can combine these. For example, `CD ..`

changes to the parent directory, and `CD ..\..`

moves you two levels "up" from the current directory.

FreeDOS also borrows a feature from Linux: You can use `CD -`

to jump back to your previous working directory. That is handy after you change into a new path to do one thing and want to go back to your previous work.

![Different ways to change directory](https://opensource.com/sites/default/files/u128651/11-cd.png)

opensource.com

### Changing the working drive

Under Linux, the concept of a "drive" is hidden. In Linux and other Unix systems, you "mount" a drive to a directory path, such as `/backup`

, or the system does it for you automatically, such as `/var/run/media/user/flashdrive`

. But DOS is a much simpler system. With DOS, you must change the working drive by yourself.

Remember that DOS assigns the first partition on the first hard drive as the `C:`

drive, and so on for other drive letters. On modern systems, people rarely divide a hard drive with multiple DOS partitions; they simply use the whole disk—or as much of it as they can assign to DOS. Today, `C:`

is usually the first hard drive, and `D:`

is usually another hard drive or the CD-ROM drive. Other network drives can be mapped to other letters, such as `E:`

or `Z:`

or however you want to organize them.

Changing drives is easy under DOS. Just type the drive letter followed by a colon (`:`

) on the command line, and DOS will change to that working drive. For example, on my [QEMU](https://www.qemu.org/) system, I set my `D:`

drive to a shared directory in my Linux home directory, where I keep installers for various DOS applications and games I want to test.

![Changing to the D: drive](https://opensource.com/sites/default/files/u128651/8-d-dirw.png)

opensource.com

Be careful that you don't try to change to a drive that doesn't exist. DOS may set the working drive, but if you try to do anything there you'll get the somewhat infamous "Abort, Retry, Fail" DOS error message.

![Abort, Retry, Fail on a drive that doesn't exist](https://opensource.com/sites/default/files/u128651/9-e-fail.png)

opensource.com

## Other things to try

With the `CD`

and `DIR`

commands, you have the basics of DOS navigation. These commands allow you to find your way around DOS directories and see what other subdirectories and files exist. Once you are comfortable with basic navigation, you might also try these other basic DOS commands:

`MKDIR`

or`MD`

to create new directories`RMDIR`

or`RD`

to remove directories`TREE`

to view a list of directories and subdirectories in a tree-like format`TYPE`

and`MORE`

to display file contents`RENAME`

or`REN`

to rename files`DEL`

or`ERASE`

to delete files`EDIT`

to edit files`CLS`

to clear the screen

If those aren't enough, you can find a list of [all DOS commands](http://wiki.freedos.org/wiki/index.php/Dos_commands) on the FreeDOS wiki.

In FreeDOS, you can use the `/?`

parameter to get brief instructions to use each command. For example, `EDIT /?`

will show you the usage and options for the editor. Or you can type `HELP`

to use an interactive help system.

Like any DOS, FreeDOS is meant to be a simple operating system. The DOS filesystem is pretty simple to navigate with only a few basic commands. So fire up a QEMU session, install FreeDOS, and experiment with the DOS command line. Maybe now it won't seem so scary.

## Comments are closed.