Chapter 009 - (Lecture) - Command Prompt 005

Command Prompt Overview

  • The Command Prompt (CMD) is a command-line interface used in Microsoft Windows.

  • Versions: CMD runs under various Windows versions, including Windows 10.

  • Accessing CMD: Accessed by typing "CMD" in the start menu.

Contents of the CMD Guide

  • CMD Basics

  • Folder Management

  • Copy & Move

  • Wildcards

Operating System Basics

  • An Operating System (OS) manages hardware/software resources allowing user applications to interact with the system.

  • Interfaces are categorized into two types:

    • Graphic User Interface (GUI): Uses images and icons (e.g., Windows, Android).

    • Command Line Interface (CLI): Users type commands; UNIX is a prevalent example.

Importance of CMD

  • Efficiency: CMD is quicker for certain tasks.

  • Automation: Batch scripts automate repetitive tasks in system administration.

  • Advanced Control: Certain administrative functions are only possible in CMD.

  • Resource Efficiency: Uses fewer resources than GUI.

  • Recovery Utility: Default utility for system recovery.

CMD Basics

  • Upon opening CMD, the prompt shows the current directory (e.g., C:\Users\Hassan>).

  • Basic commands include:

    • dir: Lists contents of the current directory.

    • cd: Used to change directories (navigate between folders).

Folder Management in CMD

Creating Folders

  • Commands used to manage folders:

    • md or mkdir: Creates a new folder (e.g., md NewFolder).

Navigating Between Folders

  • Command syntax:

    • cd FolderName: Changes directory to the specified folder.

    • cd ..: Moves up one directory.

    • cd \: Returns to the root directory.

Deleting Folders

  • rd or rmdir: Deletes a folder (e.g., rd FolderName).

Creating Files in CMD

  • Text Files: Use copy con FileName.txt to create a text file.

  • To view the contents, use type FileName.txt.

Tree Structure Command

  • tree: Displays the folder structure of a directory (e.g., tree FolderName).

Help Commands

  • help: Displays information on commands.

  • command /?: Shows help for a specific command.

Additional CMD Commands

  • cls: Clears the screen.

  • Up/Down Arrow Keys: Navigate through command history.

  • F7: Displays command history.

  • Ctrl+C: Terminates a running command.

Command-Line Options (Switches)

  • The / symbol introduces command options to modify command behavior.

  • Example: dir /p pauses output after each screen of information.

Advanced CMD Folder Management

Creating Multiple Folders

  • Use md Folder1 Folder2 to create multiple folders in one command.

  • For nested folders, use md ParentFolder ewFolder.

Address Types

Absolute Address

  • Full path from the drive letter (e.g., C:\inft1201\class\file.txt).

Relative Address

  • Path relative to the current working directory (e.g., .. ile.txt).

Wildcards in CMD

  • Wildcards: Special characters to match filenames.

    • *: Matches groups of characters (e.g., lab* matches labs.txt, lab1.txt).

    • ?: Matches a single character (e.g., a?b matches a1b, a2b).

Using Wildcards

  • To view files with certain names:

    • dir lab*: Show files starting with "lab".

    • dir *lab*: Show files containing "lab".

Lab Exercises

  • Practice commands in various sections like creating folders, listing files, moving files, and exploring wildcards.

Conclusion

  • CMD remains a powerful tool despite the prevalence of GUIs, providing efficiency and control for advanced users.