You can use commands on the command prompt or PowerShell to perform various tasks such as navigating the file system, managing files and directories and executing commands. This is a useful skill that is beneficial when using Linux and sometimes in IT. Here are some essential commands for navigating Windows OS on command Prompt or PowerShell:
- cd:
- Change the current directory or move to the specified directory
- Usage:
- cd C:\path\to\directory
- cd .. # Move up one directory ie: parent directory
- dir
- List the contents of a directory
- Usage:
- dir
- dir /a #list all files and folders including hidden files
- md
- Creates a new directory
- Usage
- md dirname
- copy
- Copy files or directories
- Usage:
- copy source destination
- Where source is the file or directory and destination is where the file or directory is pasted on
- move
- Move or rename files or directory
- Usage:
- move source destination
- move oldname newname # Rename file
- del
- Used to delete files
- Usage:
- del filename
- ren
- Used to rename files or directories
- Usage:
- ren oldname newname
- type
- Displays the content of text files
- Usage:
- type filename.txt
- cls
- Used to clear the screen in Command prompt
- Usage:
- cls
The following commands are PowerShell specific Commands:
- Get-ChildItem
- List the contents of a directory
- Usage:
- Get-ChildItem
- New-Item
- Creates a new item which can be a file, directory, etc..
- Usage:
- New-Item -ItemType Directory dirname
- New-Item filename.txt -ItemType File
- Copy-Item
- Used to copy a file or directory
- Usage:
- Copy-Item source destination
- source being the item being copied and destination being where the item is copied to
- Move-Item
- Used to move or rename files or directories
- Usage:
- Move-Item source destination
- Move-Item oldname newname
- Remove-Item
- Used to delete files or directories
- Usage:
- Remove-Item filename
- Remove-Item dirname -Recurse
- Rename-Item
- Used to rename files or directories
- Usage:
- Rename-Item oldname newname
- Get-Content
- Displays the contents of a file
- Usage:
- Get-Content filename
- Set-Location
- Used to change the current working directory
- Usage:
- Set-Location C:\path\to\directory
- Clear-Host
- Used to clear the screen in PowerShell
- Usage:
- Clear-Host