Basic Commands - Windows: Directories in CLI

Command Line Interfaces (CLIs) in Windows

  • Two CLIs are available in Windows:
    • Command Prompt (command.exe)
    • PowerShell (powershell.exe)
  • Command Prompt:
    • Has been around for a long time.
    • Similar to the command prompt in MS DOS.
  • PowerShell:
    • Supports most of the same commands as Command Prompt.
    • Has many more commands.
    • Used for the exercises in this module.
    • Many PowerShell commands are aliases for common commands in other shells.
      • An alias is like a nickname for a command.

Listing Files and Directories

Listing Directories in the Root of the C Drive

  • The first command used is for listing files and directories.
  • The C drive is where the Windows operating system is installed.
  • To access PowerShell CLI, search for "PowerShell" in the applications list and launch the program.
  • Use the ls (list directory) command with the path to specify where to look.
    • Example: ls C:\
    • The path is a command parameter; parameters are values associated with a command.
  • The output shows all the directories in the root of the C drive.
    • The number of directories shown depends on the computer's usage.

Parent and Child Directories

  • The C drive root folder is the parent directory.
  • The contents inside are child directories.
  • Parent and child are common terms for hierarchical relationships in operating systems (OSs).
  • Example:
    • Folder "dogs" contains a folder "corgi".
    • "dogs" is the parent directory.
    • "corgi" is the child directory.

Common Child Directories

  • Program Files (x86):
    • Contains most of the installed applications and programs.
  • Users:
    • Contains user profile directories or home directories.
    • Each user who logs into Windows gets their own directory here.
  • Windows:
    • Where the Windows operating system is installed.

Getting Help

  • To see the parameters of the ls command, run:
    • Get-Help ls
    • This provides a brief summary of the command's parameters.
  • For more detailed help, use:
    • Get-Help ls -Full
    • This shows a description of each parameter and usage examples.

Displaying Hidden Files

  • To see hidden files, use the -Force parameter with the ls command.
    • Example: ls C:\ -Force
    • The -Force parameter shows hidden and system files.

Important Files and Directories Revealed by -Force

  • Recycle Bin:
    • Where deleted files are moved.
    • Files are moved here instead of being immediately deleted.
  • ProgramData:
    • Contains various data for programs installed in Program Files.