Merge pull request #24064 from robsean/patch-49

Translated
This commit is contained in:
Xingyu.Wang 2021-12-11 23:20:45 +08:00 committed by GitHub
commit dc1faa786c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 164 additions and 169 deletions

View File

@ -1,169 +0,0 @@
[#]: subject: (FreeDOS commands you need to know)
[#]: via: (https://opensource.com/article/21/4/freedos-commands)
[#]: author: (Kevin O'Brien https://opensource.com/users/ahuka)
[#]: collector: (lujun9972)
[#]: translator: (robsean)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
FreeDOS commands you need to know
======
Learn how to make, remove, copy, and do other things with directories
and files in FreeDOS.
![woman on laptop sitting at the window][1]
[FreeDOS][2], the open source implementation of DOS, provides a lightweight operating system for running legacy applications on modern hardware (or in an emulator) and for updating hardware vendor fails with a Linux-compatible firmware flasher. Getting familiar with FreeDOS is not only a fun throwback to the computing days of the past, it's an investment into gaining useful computing skills. In this article, I'll look at some of the essential commands you need to know to work on a FreeDOS system.
### Essential directory and file commands
FreeDOS uses directories to organize files on a hard drive. That means you need to use directory commands to create a structure to store your files and find the files you've stored there. The commands you need to manage your directory structure are relatively few:
* `MD` (or `MKDIR`) creates a new directory or subdirectory.
* `RD` (or `RMDIR`) removes (or deletes) a directory or subdirectory.
* `CD` (or `CHDIR`) changes from the current working directory to another directory.
* `DELTREE` erases a directory, including any files or subdirectories it contains.
* `DIR` lists the contents of the current working directory.
Because working with directories is central to what FreeDOS does, all of these (except DELTREE) are internal commands contained within COMMAND.COM. Therefore, they are loaded into RAM and ready for use whenever you boot (even from a boot disk). The first three commands have two versions: a two-letter short name and a long name. There is no difference in practice, so I'll use the short form in this article.
### Make a directory with MD
FreeDOS's `MD` command creates a new directory or subdirectory. (Actually, since the _root_ is the main directory, all directories are technically subdirectories, so I'll refer to _subdirectories_ in all examples.) An optional argument is the path to the directory you want to create, but if no path is included, the subdirectory is created in the current working subdirectory.
For example, to create a subdirectory called `letters` in your current location:
```
`C:\HOME\>MD LETTERS`
```
This creates the subdirectory `C:\letters`.
By including a path, you can create a subdirectory anywhere:
```
`C:\>MD C:\HOME\LETTERS\LOVE`
```
This has the same result as moving into `C:\HOME\LETTERS` first and then creating a subdirectory there:
```
C:\CD HOME\LETTERS
C:\HOME\LETTERS\>MD LOVE
C:\HOME\LETTERS\>DIR
LOVE
```
A path specification cannot exceed 63 characters, including backslashes.
### Remove a directory with RD
FreeDOS's `RD` command removes a subdirectory. The subdirectory must be empty. If it contains files or other subdirectories, you get an error message. This has an optional path argument with the same syntax as `MD`.
You cannot remove your current working subdirectory. To do that, you must `CD` to the parent subdirectory and then remove the undesired subdirectory.
### Delete files and directories with DELTREE
The `RD` command can be a little confusing because of safeguards FreeDOS builds into the command. That you cannot delete a subdirectory that has contents, for instance, is a safety measure. `DELTREE` is the solution.
`DELTREE` deletes an entire subdirectory "tree" (a subdirectory), plus all of the files it contains, plus all of the subdirectories those contain, and all of the files _they_ contain, and so on, all in one easy command. Sometimes it can be a little _too_ easy because it can wipe out so much data so quickly. It ignores file attributes, so you can wipe out hidden, read-only, and system files without knowing it.
You can even wipe out multiple trees by specifying them in the command. This would wipe out both of these subdirectories in one command:
```
`C:\>DELTREE C:\FOO C:\BAR`
```
This is one of those commands where you really ought to think twice before you use it. It has its place, definitely. I can still remember how tedious it was to go into each subdirectory, delete the individual files, check each subdirectory for contents, delete each subdirectory one at a time, then jump up one level and repeat the process. `DELTREE` is a great timesaver when you need it. But I would never use it for ordinary maintenance because one false move can do so much damage.
### Format a hard drive
The `FORMAT` command can also be used to prepare a blank hard drive to have files written to it. This formats the `D:` drive:
```
`C:\>FORMAT D:`
```
### Copy files
The `COPY` command, as the name implies, copies files from one place to another. The required arguments are the file to be copied and the path and file to copy it to. Switches include:
* `/Y` prevents a prompt when a file is being overwritten.
* `/-Y` requires a prompt when a file is being overwritten.
* `/V` verifies the contents of the copy.
This copies the file `MYFILE.TXT` from the working directory on `C:` to the root directory of the `D:` drive and renames it `EXAMPLE.TXT`:
```
`C:\>COPY MYFILE.TXT D:\EXAMPLE.TXT`
```
This copies the file `EXAMPLE.TXT` from the working directory on `C:` to the `C:\DOCS\` directory and then verifies the contents of the file to ensure that the copy is complete:
```
`C:\>COPY EXAMPLE.TXT C:\DOCS\EXAMPLE.TXT /V`
```
You can also use the `COPY` command to combine and append files. This combines the two files `MYFILE1.TXT` and `MYFILE2.TXT` and places them in a new file called `MYFILE3.TXT`:
```
`C:\>COPY MYFILE1.TXT+MYFILE2.TXT MYFILE3.TXT`
```
### Copy directories with XCOPY
The `XCOPY` command copies entire directories, along with all of their subdirectories and all of the files contained in those subdirectories. Arguments are the files and path to be copied and the destination to copy them to. Important switches are:
* `/S` copies all files in the current directory and any subdirectory within it.
* `/E` copies subdirectories, even if they are empty. This option must be used with the `/S` option.
* `/V` verifies the copies that were made.
This is a very powerful and useful command, particularly for backing up directories or an entire hard drive.
This command copies the entire contents of the directory `C:\DOCS`, including all subdirectories and their contents (except empty subdirectories) and places them on drive `D:` in the directory `D:\BACKUP\DOCS\`:
```
`C:\>XCOPY C:\DOCS D:\BACKUP\DOCS\ /S`
```
### Using FreeDOS
FreeDOS is a fun, lightweight, open source operating system. It provides lots of great utilities to enable you to get work done on it, whether you're using it to update the firmware of your motherboard or to give new life to an old computer. Learn the basics of FreeDOS. You might be surprised at how versatile it is.
* * *
_Some of the information in this article was previously published in [DOS lesson 8: Format; copy; diskcopy; Xcopy][3]; [DOS lesson 10: Directory commands][4] (both CC BY-SA 4.0); and [How to work with DOS][5]._
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/4/freedos-commands
作者:[Kevin O'Brien][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/ahuka
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop)
[2]: https://www.freedos.org/
[3]: https://www.ahuka.com/dos-lessons-for-self-study-purposes/dos-lesson-8-format-copy-diskcopy-xcopy/
[4]: https://www.ahuka.com/dos-lessons-for-self-study-purposes/dos-lesson-10-directory-commands/
[5]: https://allaboutdosdirectoires.blogspot.com/

View File

@ -0,0 +1,164 @@
[#]: subject: (FreeDOS commands you need to know)
[#]: via: (https://opensource.com/article/21/4/freedos-commands)
[#]: author: (Kevin O'Brien https://opensource.com/users/ahuka)
[#]: collector: (lujun9972)
[#]: translator: (robsean)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
你需要知道的 FreeDOS 命令
======
学习如何在 FreeDOS 中制作,移除,复制,或执行其它的目录和文件作业。
![woman on laptop sitting at the window][1]
[FreeDOS][2] DOS 的开放源文件的实现, 提供一个轻量级的操作系统,在现代硬件 (或在一个模拟器) 上用于运行历史遗留下来的应用程序,硬件供应商用于更新不兼容 Linux 的固件闪存。熟悉 FreeDOS 不仅是一种旧计算机时代的有趣考古,也是一种获取有用的计算机技能的投资。在这篇文章中,我将查看一些在 FreeDOS 系统上工作的所需要知道的必不可少的命令。
### 必不可少的命令和文件命令
FreeDOS 在一个硬盘驱动器上使用目录来组织文件。这意味着你需要使用目录命令来创建一个结构,用于存储和查找你在其中存储的文件。你所需要的用于管理目录结构的命令:
* `MD` (或 `MKDIR`) 创建一个新的目录或子目录。
* `RD` (或 `RMDIR`) 移除 (或删除) 一个目录或子目录。
* `CD` (或 `CHDIR`) 从当前工作目录更改到另一个命令。
* `DELTREE` 擦除一个目录,包括其包含的任意文件或子目录。
* `DIR` 列出当前工作目录的内容。
因为使用目录是 FreeDOS 的主要工作,所有的这些命令 (除 DELTREE 以外) 是包含在 COMMAND.COM 中的内部命令。因此,它们将被加载到 RAM 之中,并在你启动 (甚至从一个启动盘启动) 时随时可用。前三个命令有两个版本:一个版本是两个字母的短名,一个版本是长名。在实践中没有区别,因此,我将在这篇文章中使用短名。
### 使用 MD 制作一个目录
FreeDOS 的 `MD` 命令会创建一个新的目录或子目录。(实际上,由于 _root_ 是主要的目录,从技术上将,所有的目录都是子目录,因此,我更喜欢在所有的示例中使用 _子目录_ )。一个可选的参数是你所想要创建目录的路径,但是如果不包含路径,将在当前工作子目录中创建子目录。
例如,为在你的当前位置创建一个名称为 `letters` 的子目录:
```
`C:\HOME\>MD LETTERS`
```
这会创建子目录 `C:\letters`
通过包含一个路径,你可以在任意位置创建一个子目录:
```
`C:\>MD C:\HOME\LETTERS\LOVE`
```
这和先移动到 `C:\HOME\LETTERS` ,然后在其中创建一个子目录的结果相同:
```
C:\CD HOME\LETTERS
C:\HOME\LETTERS\>MD LOVE
C:\HOME\LETTERS\>DIR
LOVE
```
一次的路径描述不能超过 63 个字符,包括反斜杠。
### 使用 RD 移除一个目录
FreeDOS 的 `RD` 命令会移除一个子目录。这个子目录必需是空的。如果它包含文件或其它是子目录,你将会得到错误信息。这有一个可选的路径参数,语法与 `MD` 的相同。
你不能移除你的当前工作子目录。为移除此目录,你必需 `CD` 其父目录,然后再移除不需要的子目录。
### 使用 DELTREE 删除文件和目录
`RD` 命令可能会让人有点迷糊,因为在该命令中内置了保护 FreeDOS 的措施。例如,你不能删除一个包含内容的子目录是一种安全措施。`DELTREE` 是一中解决方案。
`DELTREE` 命令会删除整个子目录 "树" (一个子目录),加上其包含的所有的文件,加上其包含的所有的子目录及其包含的所有的文件等等,上述的一切都在一个简单的目录中完成。有时,它可能有点 _太_ 容易了,因为它可以如此快速地擦除数据。它是忽略文件属性的,因此你可以擦除隐藏的,只读的,和未知的系统文件。
你甚至可以在命令中具体指定多个目录树来擦除它们。这条命令将在一个命令中擦除这两个目录中的所有子目录:
```
`C:\>DELTREE C:\FOO C:\BAR`
```
这是这些命令中的其中一个命令,在你使用它前,你真得需要再三考虑。毫无疑问,它是有它的地位的。我仍然对转到每个子目录,删除个别的文件,检查每个子目录的内容,一次删除一个子目录, 然后再跳转到上一层目录,重复上述过程的乏味而记忆犹新。`DELTREE` 在你需要时是非常省时。但是我从不会将其用于日常维护,因为一此失误都能造成重大的损失。
### 格式化一个硬盘驱动器
`FORMAT` 命令也可以用于准备一个空白的硬盘驱动器来将文件写入其中。这将格式化 `D:` 驱动器:
```
`C:\>FORMAT D:`
```
### 复制文件
`COPY` 命令,顾名思义,将文件从一个位置复制到另一个位置。所需要的参数是:将要被复制的文件、路径、要将其复制到的文件。开关选项包含:
* `/Y` 当一个文件正在被覆盖时,防止出现一个提示。
* `/-Y` 当一个文件正在被覆盖时,需要出现一个提示。
* `/V` 验证副本的内容。
这将从 `C:` 上的工作目录中复制文件 `MYFILE.TXT``D:` 驱动器的根目录,并将其重命名为 `EXAMPLE.TXT`
```
`C:\>COPY MYFILE.TXT D:\EXAMPLE.TXT`
```
这将从 `C:` 上的工作目录中复制文件 `EXAMPLE.TXT` 到 `C:\DOCS\` 目录,接下来验证文件的内容来确保副本是完整的:
```
`C:\>COPY EXAMPLE.TXT C:\DOCS\EXAMPLE.TXT /V`
```
你也可以使用 `COPY` 命名来合并和追加文件。这个命令将合并两个文件 `MYFILE1.TXT``MYFILE2.TXT` ,并将其放置到一个新的名称为 `MYFILE3.TXT` 的文件之中:
```
`C:\>COPY MYFILE1.TXT+MYFILE2.TXT MYFILE3.TXT`
```
### 使用 XCOPY 复制目录
`XCOPY` 命令将复制整个目录以及它们的所有的子目录和这些子目录中包含的所有的文件。参数是将要复制的文件和其路径,以及将要复制到的目的地。重要的开关选项是:
* `/S` 复制当前目录及其任意子目录中的所有文件。
* `/E` 复制子目录,即使它们是空的。这个选项必须和 `/S` 一起使用。
* `/V` 验证其所制作的副本。
这是一个非常强大和有用的命令,尤其是用于备份目录或整个硬盘驱动器。
这个命令将复制目录 `C:\DOCS` 的全部内容,包括所有的子目录及其内容 (除了空的子目录以外) ,并将其放置到驱动器 `D:` 的目录 `D:\BACKUP\DOCS\` 之中:
```
`C:\>XCOPY C:\DOCS D:\BACKUP\DOCS\ /S`
```
### 使用 FreeDOS
FreeDOS 是一个有趣的,轻量的,开放源文件的操作系统。不管你正在使用它来更新你的主板的固件,还是给予旧计算机新生,它都能提供很多极好的实用程序,来使你能够很好地使用它工作。学习 FreeDOS 的基本知识。你都可能会被它的多才多艺所惊讶。
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/4/freedos-commands
作者:[Kevin O'Brien][a]
选题:[lujun9972][b]
译者:[robsean](https://github.com/robsean)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/ahuka
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop)
[2]: https://www.freedos.org/
[3]: https://www.ahuka.com/dos-lessons-for-self-study-purposes/dos-lesson-8-format-copy-diskcopy-xcopy/
[4]: https://www.ahuka.com/dos-lessons-for-self-study-purposes/dos-lesson-10-directory-commands/
[5]: https://allaboutdosdirectoires.blogspot.com/