One of my household’s first computer systems ran a command-line working system referred to as DOS, the “Disk Operating System.” I grew up with DOS, and discovered to leverage the command line to make my work simpler. And so did a whole lot of different individuals. We beloved DOS a lot that in 1994, we created the FreeDOS Project. Today on June 29, we have a good time 28 years of FreeDOS.
If you are new to FreeDOS, chances are you’ll be confused about the way to use the totally different command line packages that include it. Let’s get began with 26 of my favourite FreeDOS instructions. To study extra, add the /? possibility after most instructions to get extra info:
C:>attrib /?
ATTRIB v2.1 - Displays or modifications file attributes.
Copyright (c) 1998-2003, licensed beneath GPL2.Syntax: ATTRIB /@[list]
Options:
+H Sets the Hidden attribute. -H Clears the Hidden attribute.
+S Sets the System attribute. -S Clears the System attribute.
+R Sets the Read-only attribute. -R Clears the Read-only attribute.
+A Sets the Archive attribute. -A Clears the Archive attribute./S Process recordsdata in all directories in the required path(es).
/D Process listing names for arguments with wildcards.
/@ Process recordsdata, listed in the required file [or in stdin].Examples:
attrib file -rhs
attrib +a -r dir1 dir2*.dat /s
attrib -hs/sd /@checklist.txt *.*
A is for ATTRIB
The ATTRIB
program shows or modifications a file’s attributes. An attribute could be one among 4 values: Hidden (H), System (S), Read-only (R), and Archive (A).
Files marked as Hidden do not show in a listing itemizing. For instance, suppose you wish to “hide” a file referred to as SECRET.TXT
so nobody would realize it was there. First, you may present the attributes on that file to see its present settings:
C:FILES>attrib secret.txt
[----A] SECRET.TXT
To conceal this file, activate the Hidden attribute by utilizing the plus (+
) operator, like this:
C:FILES>attrib +h secret.txt
[----A] -> [-H--A] SECRET.TXT
C:FILES>dir
Volume in drive C is FREEDOS2022
Volume Serial Number is 333D-0B18Directory of C:FILES
. <DIR> 05-27-2022 9:22p
.. <DIR> 05-27-2022 9:22p
0 file(s) 0 bytes
2 dir(s) 279,560,192 bytes free
Another frequent manner to make use of ATTRIB
is by manipulating the Read-only attribute, so you do not unintentionally overwrite an necessary file. Suppose you wish to shield the SECRET.TXT
file so you may’t delete or change it. Turn on the Read-only attribute like this, with the +R
modifier:
C:FILES>attrib +r secret.txt
[----A] -> [---RA] SECRET.TXT
C:FILES>del secret.txt
C:FILESSECRET.TXT: Permission denied
no file eliminated.
[ Related read: How I use the attr command with my Linux filesystem ]
B is for BEEP
If it’s worthwhile to add slightly pizzazz to a batch file, you should use the BEEP
command to get the consumer’s consideration. BEEP
does not show something to the display screen, however merely generates a basic “beep” tone.
Note that BEEP
makes use of the PC’s built-in speaker to make the “beep” sound. If you boot FreeDOS utilizing a digital machine, examine that your system is ready as much as appropriately emulate the PC speaker. Otherwise, you’ll not hear something.
C is for CD
Like Linux, FreeDOS helps directories, which let you manage your recordsdata in a manner that is sensible to you. For instance, you would possibly hold all your recordsdata in a listing referred to as FILES
, and also you might need different directories inside FILES
for sure sorts of recordsdata, equivalent to DOCS
for phrase processor recordsdata, or SPRDSHT
for spreadsheet recordsdata.
You can navigate right into a listing utilizing the CD
or change listing command. The CHDIR
command is identical as CD
, when you choose to make use of that syntax.
To turn into a brand new listing, use the CD
command with the vacation spot listing:
C:>cd recordsdata
C:FILES>cd sprdsht
C:FILESSPRDSHT>dir
Volume in drive C is FREEDOS2022
Volume Serial Number is 333D-0B18
Directory of C:FILESSPRDSHT
. <DIR> 05-27-2022 9:59p
.. <DIR> 05-27-2022 9:59p
FIB WKS 2,093 05-27-2022 10:07p
LAB1 WKS 2,087 05-27-2022 10:10p
MIS100 WKS 2,232 05-27-2022 10:05p
3 file(s) 6,412 bytes
2 dir(s) 279,527,424 bytes free
You do not need to navigate one listing at a time. You can as a substitute present the total listing path you wish to change to, with one CD
command:
C:>cd filessprdsht
C:FILESSPRDSHT>dir
Volume in drive C is FREEDOS2022
Volume Serial Number is 333D-0B18
Directory of C:FILESSPRDSHT
. <DIR> 05-27-2022 9:59p
.. <DIR> 05-27-2022 9:59p
FIB WKS 2,093 05-27-2022 10:07p
LAB1 WKS 2,087 05-27-2022 10:10p
MIS100 WKS 2,232 05-27-2022 10:05p
3 file(s) 6,412 bytes
2 dir(s) 279,527,424 bytes free
D is for DELTREE
If it’s worthwhile to delete a single file, you should use the DEL
command. To take away an empty listing, you should use the RMDIR
or RD
instructions. But what if you wish to delete a listing that has numerous recordsdata and subdirectories inside it?
A listing with different directories inside it’s referred to as a listing tree. You can delete a complete listing tree with the DELTREE
command. For instance, to delete your FILES
listing, together with all of the recordsdata and directories it incorporates, kind this command:
C:>deltree recordsdata[DEFAULT-BUILD v1.02g] of DELTREE. The "ROOT-SAFETY-CHECK" is enabled.
Delete listing "C:FILES"
and all its subdirectories?[Y] [N] [Q], [ENTER] ? Y
==> Deleting "C:FILES" ...
You can simply and shortly wipe out a whole lot of work with a single DELTREE
command, so the FreeDOS DELTREE
prompts you to ask if that is actually one thing you wish to do. Use this command fastidiously.
E is for EDIT
If it’s worthwhile to edit a textual content file on FreeDOS, the EDIT
program permits you to try this shortly and simply. For instance, to begin modifying a file referred to as HELLO.TXT
, kind EDIT HELLO.TXT
. If the HELLO.TXT
file already exists, EDIT
opens the file for modifying. If HELLO.TXT
does not exist but, then EDIT
begins a brand new file for you.
FreeDOS EDIT
makes use of a pleasant interface that must be simple for most individuals to make use of. Use the menus to entry the varied options of EDIT, together with saving a file, opening a brand new file, or exiting the editor. To entry the menus, faucet the Alt key in your keyboard, then use the arrow keys to get round and Enter to pick out an motion.
F is for FIND
If it’s worthwhile to discover textual content in a file, the FIND
command does the job. Similar to fgrep
on Linux, FIND
prints traces that include a string. For instance, to examine the “Menu Default” entry within the FDCONFIG.SYS
file, use FIND
like this:
C:>discover "MENUDEFAULT" fdconfig.sys---------------- FDCONFIG.SYS
MENUDEFAULT=2,5
If you are not positive if the string you wish to discover makes use of uppercase or lowercase letters, add the /I
choice to ignore the letter case:
C:>discover /i "menudefault" fdconfig.sys
---------------- FDCONFIG.SYS
MENUDEFAULT=2,5
[ Download the cheat sheet: Linux find command ]
G is for GRAPHICS
If you wish to seize a display screen, you would possibly use the PrtScr (Print Screen) key in your keyboard to print the textual content in your monitor on to a printer. However, this solely works for plain textual content. If you wish to print graphic screens, it’s worthwhile to load the GRAPHICS
program.
GRAPHICS
helps totally different printer varieties, together with HP PCL printers, Epson dot matrix printers, and PostScript-compatible printers. For instance, if in case you have an HP laser printer related to your laptop, you may load help for that printer by typing this command:
C:>graphics hpdefault
Running in MS GRAPHICS compatibility mode...
Using HPPCL kind for kind hpdefault
If you assume this isn't right, mail me (see assist textual content).
Printing black as white and white as black
which internally makes use of /I of this GRAPHICS.
You can use the next command straight as a substitute of
GRAPHICS [your options] in the longer term:
LH GRAPH-HP /I
Note that GRAPH-HP permits further choices:
/E financial system mode, /1 use LPT1, /2 use LPT2, /3 use LPT3,
/R for random as a substitute of ordered dither
/C for 300dpi as a substitute of 600dpi
Driver to make 'shift PrtScr' key work
even in CGA, EGA, VGA, MCGA graphics
modes loaded, in HP PCL mode.
H is for HELP
If you are new to FreeDOS, you will get hints on the way to use the totally different instructions by typing HELP
. This brings up the FreeDOS Help system, with documentation on all of the instructions:
[ Read also: The only Linux command you need to know ]
I is for IF
You can add conditional statements to your command line or batch file utilizing the IF
assertion. IF
makes a easy check, then executes a single command. For instance, to print the outcome “It’s there” if a sure file exists, you may kind:
C:>if exist kernel.sys echo It's there
It's there
If you wish to check the alternative, use the NOT
key phrase earlier than the check. For instance, to print “Not equal” if two strings usually are not the identical worth, kind this:
C:>if not "a"=="b" echo Not equal
Not equal
J is for JOIN
Early DOS variations had been pretty easy; the primary model of DOS did not even help directories. To present backwards compatibility for these older packages, now we have the JOIN
program as a neat workaround. JOIN
replaces a path with a drive letter, so you may put an outdated program in its personal subdirectory, however entry it utilizing a single drive letter.
Let’s say you had an outdated utility referred to as VC
that does not perceive directories. To hold working with VC
, you may “join” its path to a drive letter. For instance:
FreeDOS implements JOIN
as SWSUBST
, which additionally combines options from the same SUBST
command. To be part of the D:VC
path to a brand new drive letter referred to as V:
, kind:
C:>swsubst v: d:vc
C:>dir v:
Volume in drive V is DATA
Volume Serial Number is 212C-1DF8Directory of V:
. <DIR> 02-21-2022 10:35p
.. <DIR> 02-21-2022 10:35p
VC COM 27,520 07-14-2019 4:48p1 file(s) 27,520 bytes
2 dir(s) 48,306,176 bytes free
Ok is for KEYB
DOS assumes a US keyboard structure by default. If your keyboard is totally different, you should use the KEYB
command to load a brand new keyboard language structure. For instance, to load a German keyboard structure, kind:
C:>keyb gr
FreeDOS KEYB 2.01 - (c) Aitor Santamaría Merino - GNU GPL 2.0
Keyboard structure : C:FREEDOSBINKEYBOARD.SYS:GR [858] (3)
L is for LABEL
FreeDOS names every floppy drive and arduous drive with a label. These labels present a helpful strategy to establish what a disk would possibly include. The LABEL
command was immensely helpful while you wanted retailer recordsdata throughout various totally different floppy disks, the place you would possibly label one floppy “Data” and one other floppy as “Games.”
To assign a brand new label to a drive, or to alter the prevailing label on a drive, use LABEL like this:
D:>label d: information
D:>dir /w
Volume in drive D is DATA
Volume Serial Number is 212C-1DF8Directory of D:
[123] [ABILITY] [ASEASY] [GAMES2] [QUATTRO]
[SRC] [TEMP] [THE] [VC] [WORD]
[WS400] EDLIN16.EXE EDLIN32.EXE MYENV.BAT
3 file(s) 113,910 bytes
11 dir(s) 48,306,176 bytes free
M is for MEM
Running packages and loading drivers takes reminiscence. To see how a lot reminiscence your system has, and the way a lot reminiscence is free for working DOS packages, use the MEM
command:
C:>memMemory Type Total Used Free
---------------- -------- -------- --------
Conventional 639K 11K 628K
Upper 104K 18K 86K
Reserved 281K 281K 0K
Extended (XMS) 15,224K 537K 14,687K
---------------- -------- -------- --------
Total reminiscence 16,248K 847K 15,401K
Total beneath 1 MB 743K 29K 714K
Total Expanded (EMS) 8,576K (8,781,824 bytes)
Free Expanded (EMS) 8,192K (8,388,608 bytes)
Largest executable program measurement 628K (643,104 bytes)
Largest free higher reminiscence block 84K ( 85,728 bytes)
FreeDOS is resident in the excessive reminiscence space.
N is for NANSI
If you wish to add slightly shade to the FreeDOS command line, you should use ANSI escape sequences. These sequences are so named as a result of every begins with code 33 (the ESC
character) and a particular sequence of characters, as outlined by the American National Standards Institute, or ANSI.
FreeDOS helps ANSI escape sequences via the NANSI.SYS
driver. With NANSI
loaded, your FreeDOS console interprets the ANSI escape sequences, equivalent to setting the textual content colours.
O is for oZone
FreeDOS is a command line working system, however some of us choose to make use of a graphical consumer interface as a substitute. That’s why FreeDOS 1.3 contains a number of graphical desktops. One desktop I like is known as oZone, which supplies a glossy, modern-looking interface.
Note that oZone has a number of annoying bugs, and will use some love from a developer on the market. If you are involved in making oZone even higher, be at liberty to obtain the supply code.
P is for PROMPT
The normal FreeDOS command-line immediate tells you the place you might be within the filesystem. When you first boot FreeDOS, your immediate appears like C:>
, which suggests the “” (root) listing on the “C:” drive. The “>” character signifies the place you may kind a command.
If you like totally different info in your immediate, use the PROMPT
command to alter it. You can characterize totally different info with a particular code preceded with $
, equivalent to $D
for the date and $T
for the time. For instance, you may make your FreeDOS command line appear to be a Linux immediate with the $$
instruction, to print a single greenback signal:
C:>immediate $$
$
Type PROMPT /?
to see a listing of all particular codes.
Q is for QBASIC
FreeDOS does not even have QBASIC. That was a proprietary BASIC programming surroundings for MS-DOS. Instead, we offer a number of open supply compilers, together with some for BASIC programming.
The FreeBASIC Compiler ought to compile most QBASIC packages on the market. Here’s a easy “guess the number” instance:
dim quantity as integer
dim guess as integer
randomize timer
quantity = int( 10 * rnd() ) + 1
print "Guess the number from 1 to 10:"
do
enter guess
if guess < quantity then print "Too low"
if guess > quantity then print "Too high"
loop whereas guess <> quantity
print "That's right!"
Use the FBC
command to compile this system with FreeBASIC:
C:DEVELFBC>fbc guess.bas
Here’s a fast demonstration of that easy sport:
C:DEVELFBC>guess
Guess the quantity from 1 to 10:
? 5
Too excessive
? 3
Too low
? 4
That's proper!
[ Read next: Learn Fortran by writing a “guess the number” game ]
R is for REM
Comments are nice when writing packages; feedback assist us perceive what this system is meant to do. You can do the identical in batch recordsdata utilizing the REM
command. Anything after the REM
is ignored in a batch file.
S is for SET
The FreeDOS command line makes use of a set of variables referred to as surroundings variables that allow you to customise your system. You can set these variables with the SET
command. For instance, use the DIRCMD
variable to manage how DIR
arranges listing listings. To set the DIRCMD
variable, use the SET
command:
This tells DIR
to order (O) the output by grouping (G) directories first, then sorting the outcomes by title (N) and extension (E).
T is for TYPE
The TYPE
command is without doubt one of the most-often used DOS instructions. TYPE
shows the contents of a file, much like cat
on Linux.
C:DEVEL>kind hey.c
#embraceint
important()
{
places("Hello world");
return 0;
}
U is for UNZIP
On Linux, chances are you’ll be acquainted with the usual Unix archive command: tar
. There’s a model of tar on FreeDOS too (and a bunch of different in style archive packages), however the de facto normal archiver on DOS is ZIP
and UNZIP
. Both are put in in FreeDOS 1.3 by default.
Let’s say I had a zipper archive of some recordsdata. If I wish to extract all the Zip file, I may simply use the UNZIP
command and supply the Zip file as a command-line possibility. That extracts the archive beginning at my present working listing. Unless I’m restoring a earlier model of one thing, I normally do not wish to overwrite my present recordsdata. In that case, I’ll wish to extract the archive to a brand new listing. You can specify the vacation spot path with the -d
(“destination”) command-line possibility:
D:SRC>unzip monkeys.zip -d monkeys.new
Warning: TZ surroundings variable not discovered, can not use UTC instances!!
Archive: monkeys.zip
creating: monkeys.new/monkeys/
inflating: monkeys.new/monkeys/banana.c
inflating: monkeys.new/monkeys/banana.obj
inflating: monkeys.new/monkeys/banana.exe
creating: monkeys.new/monkeys/putimg/
inflating: monkeys.new/monkeys/putimg/putimg.c
inflating: monkeys.new/monkeys/putimg/putimg.obj
inflating: monkeys.new/monkeys/putimg/putimg.exe
To study extra concerning the ZIP
and UNZIP
instructions, learn How to archive files on FreeDOS.
V is for VER
In the outdated days of DOS, the VER
command reported the DOS distribution you had been working, equivalent to “MS-DOS 5.0.D” With FreeDOS, the VER
command offers you extra particulars, such because the model of the FreeDOS Shell:
C:DEVEL>ver
FreeCom model 0.85a - WATCOMC - XMS_Swap [Jul 10 2021 19:28:06]
If you additionally wish to see the FreeDOS kernel model and the DOS compatibility stage, add the /R
possibility:
C:DEVEL>ver /rFreeCom model 0.85a - WATCOMC - XMS_Swap [Jul 10 2021 19:28:06]
DOS model 7.10
FreeDOS kernel 2043 (construct 2043 OEM:0xfd) [compiled May 14 2021]
W is for WHICH
The FreeDOS command line can run packages from a listing of various directories, recognized in a PATH
variable. You can use the WHICH
command to establish precisely the place a program is positioned. Just kind WHICH
plus the title of this system you wish to find:
C:>which xcopy
xcopy C:FREEDOSBINXCOPY.EXE
X is for XCOPY
The COPY
command copies solely recordsdata from one place to a different. If you wish to prolong the copy to incorporate any directories, use the XCOPY
command as a substitute. I normally add the /E
possibility to incorporate all subdirectories, together with empty ones, so I can copy all the listing tree. This makes an efficient backup of any venture I’m engaged on:
D:SRC>xcopy /e monkeys monkeys.bak
Does MONKEYS.BAK specify a file title
or listing title on the goal (File/Directory)? d
Copying D:SRCMONKEYSPUTIMGPUTIMG.C
Copying D:SRCMONKEYSPUTIMGPUTIMG.OBJ
Copying D:SRCMONKEYSPUTIMGPUTIMG.EXE
Copying D:SRCMONKEYSBANANA.C
Copying D:SRCMONKEYSBANANA.OBJ
Copying D:SRCMONKEYSBANANA.EXE
6 file(s) copied
Y is for Yellow
This is not a command, however fascinating trivia about how DOS shows colours. If you’ve got seemed fastidiously at FreeDOS, you’ve got most likely seen that textual content solely is available in a restricted vary of colours—sixteen textual content colours, and eight background colours.
The IBM 5153 shade show offered shade to the consumer by lighting up tiny crimson, inexperienced, and blue phosphor dots at totally different brightness ranges to create a palette of 16 textual content colours and eight background colours. Early PCs may solely show the background shade within the “normal intensity” stage; solely textual content colours may use shiny colours.
If you take a look at the textual content colours, you’ve gotten black, blue, inexperienced, cyan, crimson, magenta, orange, and white. The “bright” variations of those colours are shiny black (a uninteresting grey), shiny blue, shiny inexperienced, shiny cyan, shiny crimson, shiny magenta, yellow, and shiny white. The “bright” model of orange is definitely yellow. There isn’t any “bright orange.”
If you wish to study extra about textual content colours, learn our article about Why FreeDOS has 16 colors.
Z is for ZIP
You can use ZIP
on the DOS command line to create archives of recordsdata and directories. This is a helpful strategy to make a backup copy of your work or to launch a “package” to make use of in a future FreeDOS distribution. For instance, for instance I wished to make a backup of my venture supply code, which incorporates these supply recordsdata:
D:SRC>zip -9r monkeys.zip monkeys
zip warning: TZ surroundings variable not discovered, can not use UTC instances!!
including: monkeys/ (saved 0%)
including: monkeys/banana.c (deflated 66%)
including: monkeys/banana.obj (deflated 26%)
including: monkeys/banana.exe (deflated 34%)
including: monkeys/putimg/ (saved 0%)
including: monkeys/putimg/putimg.c (deflated 62%)
including: monkeys/putimg/putimg.obj (deflated 29%)
including: monkeys/putimg/putimg.exe (deflated 34%)
ZIP sports activities a ton of command-line choices to do various things, however the command line choices I exploit most are -r
to course of directories and subdirectories recursively, and -9
to supply the utmost compression attainable. ZIP
and UNZIP
use a Unix-like command line, so you may mix choices behind the sprint: -9r
offers most compression and embrace subdirectories within the Zip file.
For extra particulars about the way to use the ZIP
and UNZIP
instructions, learn How to archive files on FreeDOS.
New FreeDOS guides
Ready for the following step in your FreeDOS journey? Check out our new eBooks and begin experimenting with FreeDOS now!