Everything you do in the open source FreeDOS operating system is done from the command line. The command line begins with a prompt, which is the computer's way of saying, "I'm ready. Give me something to do." You can configure your prompt's appearance, but by default, it's:
From the command line, you can do two things: Run an internal command or run a program. External commands are programs found in separate files in your
FDOS directory, so running programs includes running external commands. It also means running the application software you use to do things with your computer. You can also run a batch file, but in that case, all you're doing is running a series of commands or programs that are listed in the batch file.
Executable application files
FreeDOS can run three types of application files:
- COM is a file in machine language less than 64KB in size.
- EXE is a file in machine language that can be larger than 64KB. EXE files also have information at the beginning of the file telling DOS what type of file it is and how to load and run it.
- BAT is a batch file written with a text editor in ASCII text format containing FreeDOS commands that are executed in batch mode. This means each command is executed in sequence until the file ends.
If you enter an application name that FreeDOS does not recognize as either an internal command or a program, you get the error message Bad command or filename. If you see this error, it means one of three things:
- The name you gave is incorrect for some reason. Possibly you misspelled the file name, or maybe you're using the wrong command name. Check the name and the spelling and try again.
- Maybe the program you are trying to run is not installed on the computer. Verify that it is installed.
- The file does exist, but FreeDOS doesn't know where to find it.
The final item on this list is the subject of this article, and it's referred to as the
PATH. If you're used to Linux or Unix already, you may already understand the concept of the PATH variable. If you're new to the command line, the path is an important thing to get comfortable with.
When you enter the name of an executable application file, FreeDOS has to find it. FreeDOS looks for the file in a specific hierarchy of locations:
- First, it looks in the active directory of the current drive (called the working directory). If you're in the directory
C:\FDOS, and you type in the name
FOOBAR.EXE, FreeDOS looks in
C:\FDOSfor a file with that name. You don't even need to type in the entire name. If you type in
FOOBAR, FreeDOS looks for any executable file with that name, whether it's
FOOBAR.BAT. Should FreeDOS find a file matching that name, it runs it.
- If FreeDOS does not find a file with the name you've entered, it consults something called the
PATH. This is a list of directories that DOS has been instructed to check whenever it cannot find a file in the current active directory.
You can see your computer's path at any time by using the
PATH command. Just type
path at the FreeDOS prompt, and FreeDOS returns your path setting:
The first line is the prompt and the command, and the second line is what the computer returned. You can see that the first place DOS looks is
FDOS\BIN, which is located on the
C drive. If you want to change your path, you can enter a path command and the new path you want to use:
In this example, I set my path to my personal
BIN folder, which I keep in a custom directory called
HOME, and then to
FDOS\BIN. Now when you check your path:
The path setting is processed in the order that directories are listed.
You may notice that some characters are lower case and some upper case. It really doesn't matter which you use. FreeDOS is not case-sensitive and treats everything as an upper-case letter. Internally, FreeDOS uses all upper-case letters, which is why you see the output from your commands in upper case. If you type commands and file names in lower case, a converter automatically converts them to upper case, and they are executed.
Entering a new path replaces whatever the path was set to previously.
The autoexec.bat file
The next question you might have is where that first path, the one FreeDOS uses by default, came from. That, along with several other important settings, is defined in the
AUTOEXEC.BAT file located at the root of your
C drive. This is a batch file that automatically executes (hence the name) when you start FreeDOS. You can edit this file with the FreeDOS program
EDIT. To see or edit the contents of this file, enter the following command:
This line appears near the top:
This line defines the value of the default path.
After you look at
AUTOEXEC.BAT, you can exit the EDIT application by pressing the following keys in order:
You can also use the keyboard shortcut Alt+X.
Using the full path
If you forget to include
C:\FDOS\BIN in your path, you won't have immediate access to any of the applications stored there because FreeDOS won't know where to find them. For instance, imagine I set my path to my personal collection of applications:
Applications built into the command line still work:
C:\cd HOME C:\HOME>dir ARTICLES BIN CHEATSHEETS GAMES DND
However, external commands fail:
C:HOME\ARTICLES>BZIP2 -c example.txt Bad command or filename - "BZIP2"
You can always execute a command that you know is on your system but not in your path by providing the full path to the file:
C:HOME\ARTICLES>C:\FDOS\BIN\BZIP2 -c example.txt C:HOME\ARTICLES>DIR example.txb
You can execute applications from external media or other directories the same way.
Generally, you probably want to keep
C:\PDOS\BIN in your path because it contains all the default applications distributed with FreeDOS.
Unless you change the path in
AUTOEXEC.BAT, the default path is restored after a reboot.
Now that you know how to manage your path in FreeDOS, you can execute commands and maintain your working environment in whatever way works best for you.
Thanks to DOS Lesson 5: The Path (published under a CC BY-SA 4.0 license) for some of the information in this article.