Command Line Interface on Windows 10

This post is lesson 40 of 42 in the subject Computer Hardware

Command Prompt, also known as Command Line Interface (CLI), is a tool used to interact with the computer via text commands. This article will introduce the basics of using Command Prompt in Windows.

1. MS-DOS (Microsoft Disk Operating System)

MS-DOS is an operating system with a Command Line Interface (CLI). It was created by Microsoft Corporation and introduced in May 1982. MS-DOS is a single-tasking operating system, meaning it only allows one application to run at a time. Later versions of Windows are multi-tasking operating systems. MS-DOS was the predecessor to the Windows operating system.

MS DOS (MicroSoft Disk Operating System)

Later Microsoft Operating Systems became easier to use with the Windows interface. However, Microsoft OS still has the command line interface with Command Prompt (CMD).

Command Prompt on Windows 10

To use CMD, press Windows + R key combination, then type cmd.exe.

2. Commands in CLI

2.1. Commands for Files and Directories

A file stores information and the operating system identifies files by their names.

filename = <name>.[extension]

In there:

  • name: This field is required and can have up to 255 characters using only alphanumeric characters and underscores. Please do not use spaces.
  • extension: This field is optional and can be up to 3 characters. It may be used to determine the file type.

The files BAITAP.TXT, HOSO.DOC, and HO_SO.DOC are considered good examples. However, BAI!.TXT, BAI TAP.DOC, and HOSO..DOC are considered invalid examples.

The Folder is where you keep your files and subdirectories. Every partition has a root directory that is represented by “\”.

Note: Avoid using the following names when naming files or folders: CON, COM1, COM2, PRN, LPT1, LPT2, as they are reserved device names.

The path refers to the location of a folder or file. The path starts at the root directory (which comes after the partition name), and consists of folders separated by a “\”. For example, C:\Teaching\exercise.txt.

There are two types of paths:

  • The absolute path starts from the partition. For example, C:\Teaching\Exercise\Programming
  • A relative path is a path that does not start from the partition. When using relative paths, you must specify the current directory. For example, Exercise\Programming in the current directory C:\Teaching.

#help command

To learn the syntax of any command, use the help command. For instance, to learn about the syntax of the dir command, type help dir.

#Command to change the current partition

For example, change partition E, type “E:” command, and then press enter.

Change current partition in CMD

#Command to view the list of files and directories

DIR [path] /P /S /A

Here are your options:

  • /P (page): View the document one page at a time.
  • /S (sub-directory): View a list of files within the directory, including subdirectories.
  • /A (attribute): View files with any attribute.

#Command to change the current directory

CD [path]

#Command to create a directory

MD [path]\[directoryname]

You can use MD C:\g\h\t to create three nested folders in the C partition.

#View tree-structured directory

TREE [path] /F |MORE

In there, /F (File): including file names in each directory, |MORE: stop each page.

#Remove Directory

RD [path] /S /Q

In there, /S (sub-directory): delete all directories and sub-files, /Q (Quiet): delete without asking.

2.2. Some other basic commands

#Create a text file

COPY CON [path]\[filename]

To save, press F6 or Ctrl-Z after creating. If needed, cancel with Ctrl-C. For instance, create the file EXERCISE.TXT in the SHAPE folder.

COPY  CON  C:\MATH\SHAPE\EXERCISE.TXT

Then, you press enter and type the contents of the file.

<type the contents of the file here> <F6>

Finally, you press enter to save the file.

#View the contents of a text file

TYPE [path] |MORE

#Rename files

REN [path]\[oldfilename] [newfilename]

For example: Rename the file EXERCISE.TXT in the MATH folder to EXC.DOC:

REN C:\MATH\EXERCISE.TXT EXC.DOC

#Move files and directories

MOVE [currentpath] [newfolderpath]

For example: Move file EXERCISE.TXT from MATH folder to PHYSICS folder:

MOVE C:\MATH\EXERCISE.TXT C:\PHYSICS

#Delete files

DEL [filepath]

For example: Delete files with extension TXT in the SHAPE folder:

DEL C:\MATH\SHAPE\*.TXT

5/5 - (1 vote)
Previous and next lesson in subject<< Steps to install Windows 10 operating systemHow to calculate RAM bandwidth on the motherboard >>

Leave a Reply

Your email address will not be published. Required fields are marked *