Almost everyone in the world either has access to a computer or owns a personal computer that uses a hard or optical disk for storage. Outside of Windows or Apple based GUI software, there is a basic and common language to communicate with the hardware of your computer. Using the Disk Operation System tool (DOS), a user can control the operation of their PC using an array of basic DOS commands.

DOS commands can provide you with a wide variety of functions including; file management, memory management, and program loading. In this article, we will introduce you to 15 basic commands that will give you a strong foundation of DOS commands.

What Are DOS Commands?

monitor on black in background

Image Source : pixabay

DOS commands are a sequence of numeric values (that often serve as shorthand for executable functions) that when entered, into a command-line interface, task the computer to perform certain operations. It is software written to control hardware which is often run under larger more complex software applications. Originally mass marked in the early 80s by Microsoft, it is still the basis of more advanced operating systems used today.

Change the Default Drive

USB drives

Image Source : pixabay

The first of the DOS commands we will discuss is changing the default drive. Computer drives can be thought of different aisles in a grocery store. If you are looking for a specific food item (file), you have to be looking in the right aisle (drive).

In order to change the default drive, type the letter of the drive you wish to switch to. The new default will be listed in the subsequent DOS prompts. Listed below is an example:

C> E: [enter]

Changes the default drive from C to E

E> C: [enter]

Changes the default drive from E to C

Remember to execute a DOS command you must press the Enter key, represented above by [enter].

Change Directory Command

Folder

Image Source : pixabay

Once in the desired drive, you can now navigate from directory to directory using the “CD” command (change directory).For example:

C> cd dishware [enter]

Moves you to the directory called ‘DISHWARE’

C> cd dishwarebowl [enter]

Moves you to the directory called ‘CHAIRS’ under the directory called ‘FURNITURE’

C> cd .. [enter]

Moves you up one level in the path

C> cd [enter]

Takes you back to the root directory (C: in this case)

Create a Directory Command

Laptop and coffee on the table

Image Source: pixabay

There is also a DOS command that allows users to create or make new directories to store files. Depending on user permissions, the MKDIR or MD (make directory command) will make a new directory within the current directory; if it does not already exist.

C> mkdir countries [enter]

Creates a directory called ‘COUNTRIES’

Directory List Command

To list the names and sizes of all files located on a particular drive or disk, enter the DIR (Directory) command. The directory list command has many options as well. Including file names and size, the command can also give you information about the date and time the file was last modified.

C> dir a: [enter]

Shows directory of drive A

C> dir b: [enter]

Shows directory of drive B

C> dir agis [enter]

Shows files in a subdirectory on drive C (default)

C> dir [enter]

Shows directory of drive C

C> dir /w [enter]

Shows directory in wide format, as opposed to a vertical listing.

DIR Options

Adding ‘*’ and ‘?’ characters to your DIR command can add extra filters to your file listing. Uses for these qualifiers are illustrated below:

C> dir a:*.exe [enter]

Lists all files on the A drive with an extension of ‘EXE’

C> dir b:students.* [enter]

Lists all files on the B drive with a filename of ‘STUDENTS’

The asterisk allows users to enter a partial specification to find a file. It because even more useful when trying to retrieve a group of files with the same filename or extension. Similarly, ‘?’ permits wild-card searches focused on a single character.

Example:

C> dir a:labe?.txt

Lists all five-letter files with the first four letters ‘LABE’ and an extension of ‘TXT’

C> dir b:format.e??

Lists all files with a filename of ‘FORMAT’ and an extension beginning with ‘E’

The two characters can even be combined for a third option. For example:

C> dir a:labe?.*

Lists all five-letter files with the first four letters ‘LABE’ and any extension

C> dir c:*.ex?

Lists all files with an extension beginning with ‘EX’

  Remove Directory Command

Further directory management is offered with the RMDIR (RD) command to remove directories. This command can only be executed if the directory chosen is empty.

Example:

C>rd new_file

Removes directory called ‘NEW_FILE’

Copy Command

sticky note and keyboard

Image Source : pixabay

Another useful DOS command is the copy command. It can be used to copy files or directories from one disk to another. It can also be sued to create a duplicate copy of a file on the same disk. Below we will see examples of some of the more basic operations of the copy command.

Example:

C> copy C:translate.exe E: [enter]

Copies the file ‘TRANSLATE.EXE’ from the C drive to the E drive and gives it the same name

C> copy E:constants.dat C:equationsconstants2.dat [enter]

Creates a copy of ‘CONSTANTS.DAT’ from drive E on to drive C, putting it in the ‘EQUATIONS’ subdirectory and renaming it ‘CONSTANTS2.DAT’

To correctly use the copy command, it is important to remember that the first file listed after the copy command is the source file, and the second is the target file. The source file gets copied, and the target file will be the name of the new file. If a unique target file name is not given, the new file will have the exact name as the source file.

Example:

C> copy a:myfile.txt b: [enter]

C> copy c:command.com b:com.com [enter]

C> copy b:golly.gee a:whao.boy [enter]

C> copy command.* a: [enter]

C> copy a:mymap.dwg c:maps [enter]

It is good practice to use the complete file specifications for both the source and target files. Incomplete or incorrect file names may result in errors or failed commands. Another feature or shortcut is to use the “*” key as a wild-character to represent any file extension.

Erase Command

delete/remove

Image Source : pixabay

The ERASE command is used to delete a specified file. Due to its easy use, it is one of the most dangerous commands. Once a file is deleted, it is gone forever unless there is backup saved.  For this reason, it is best practice to use a complete file specification with the ERASE command as a safety precaution.

C> erase E:myfile.txt

Erases the file MYFILE.TXT from the diskette in the E drive

If no drive specification is entered, the system looks to delete the specified file from drive C (in this case)

Format Command

floppy disk

Image Source : pixabay

The FORMAT command can be one of the most dangerous DOS commands if it is used incorrectly. For a computer to use a new disk, the disk must first be formatted. That means the diskette is checked for flaws and a directory structure is written for the storage of the diskette’s files. But if the disk already contains files and the format command is executed, it will result in the deletion of all the contents of the entire disk.

C> format c: [enter]

Formats the diskette in the C drive

Once the command is entered, the user with prompted with instructions to complete the process. The system will ask the user if you wish to format more diskettes. If you are choosing only one diskette, type N (No), but if you wish to format several diskettes, type Y (Yes).

Rename Command

rename on folder

Image Source : pixabay

The RENAME command permits users to alter the name of a file without making a copy of it. One thing to remember is that the file name and extension must be complete for the source file and no drive specification is given for the target. Also, renaming can only occur on a single disk drive (otherwise the copy command must be used).

Example:

C> ren a:table2.txt table_2.txt

Changes the name of ‘TABLE2.TXT’ on the A drive to ‘TABLE_2.TXT’.

Stop Execution

Stop on white surface

Image Source : pixabay

Also known as Ctrl-Break the command, the stop execution halts computer commands in the middle of executing. Ctrl-Break might be blocked in some software packages in certain situations. The Ctrl and Break button must be pressed simultaneously. The Break key is typically located near the print screen and scroll lock.

C> [ctrl]+[break]

Change the Date

calendar on table

Image Source : pixabay

To change the date, simply type ‘date’ and enter the desired date by the format specified at the prompt.

C> date [enter]

The current date is: Day mm/dd/yyyy

Enter the new date: (mm-dd-yy)

Change the Time

clock on white surface

Image Source : pixabay

Changing the system time only requires typing ‘time’ and enter the desired time according to the format specified.

C>time [enter]

The current time is: XX:XX:XX.XX

Enter the new time: 

Lock the Hard Drive

Lock and cable

Image Source : pixabay

The lock allows a user to lock a drive, to enable direct disk access for an application. Unlock can be used to unlock the drive, disabling direct disk access for an application.

Example:

C> LOCK [drive:] [enter]

C> UNLOCK[drive:] [enter]

When using the command the following prompt will appear:“WARNING: The LOCK command enables direct access by programs that can CORRUPT file names and destroy disk data, resulting in the loss of files on your disk. Are you sure (Y/N)?”

Undelete a File

To restore files that may have been deleted, ‘undelete’ can be written before a directory path and file name. Like the list command, many options can be executed to customize your file recovery needs.

Example:

C>undelete c:lostdata.txt [enter]

Some common undelete syntax additions are ‘/all’, ‘/list’, and ‘/load’

Exit DOS

exit on black surface

Image Source : pixab​​ay

In order to withdrawal from the currently running application, the user only needs to enter ‘exit’ into the command line.

Example:

C>exit [enter]

The user can also specify what program or application you can exit out of. Adding a ‘/B’ will exit the current batch script instead of the command line.

Conclusion

Disk Operation System is a powerful tool that gives users direct access to a computers control hardware. These 15 basic DOS commands can be a strong foundation for any user to execute file and directory management functions.

Hopefully, this quick introduction into DOS commands sparks interests into the full range of tasks that are built into all computer operating systems.