Post

PowerShell 102 - Getting Comfortable with PowerShell Terminal!

Discover the essentials of terminal commands in this guide, from installation and configuration to understanding basic commands like 'ls', 'cd', and 'cp' — perfect for beginners!



Note, we will interchangeably use word folder and directory.

WHAT IS WINDOWS TERMINAL?

Windows Terminal is a modern host application for the command-line shells you already love, like Command Prompt, PowerShell, and bash (via Windows Subsystem for Linux (WSL)).

Its main features include multiple tabs, panes, Unicode and UTF-8 character support, a GPU accelerated text rendering engine, and the ability to create your own themes and customize text, colors, backgrounds, and shortcuts.

STEPS TO INSTALL

  1. Search for Microsoft Store on your Windows search bar and click to open
  2. On Microsoft Store's search bar, search for Windows Terminal
  3. Click on Install/Get
  4. Once installed, you can simply open it as a normal install application on your Windows machine

TERMINAL APP CONFIGURATION

  1. Open Windows Terminal
  2. Click on Drop Down menu & then click on Settings
  3. Click on Windows PowerShell in Left panel
  4. Now you can try changing the setting the way you want your Terminal to look like. The settings are pretty self explanatory.

KNOW YOUR TERMINAL

Terminal looks like this when you launch it:

1
PS C:\Users\Kamal >

The C:\Users\Kamal This is the path on which your terminal is actually pointing to. If you run any command which needs path as parameter, this will be used as default. You can change this path using cd <new-path>

THE “ls” COMMAND

This command is used to get files and folders in your current directory (or in any directory).

List Files & Folders

1
2
3
4
5
# List items in current folder
ls

# List items in any folder
ls C:\Users\Kamal\AppData\Local

Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
ls

    Directory: D:\

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          25-08-2024    13:55                .old
d----          08-08-2024    08:45                ConfigBackup
d----          25-08-2024    14:30                Demo
d----          25-07-2024    18:57                Games
d-r--          25-08-2024    18:59                Projects
d----          25-08-2024    14:01                RandomData
d----          29-05-2024    12:38                Remote
1
2
3
4
5
6
7
8
ls D:\Demo

    Directory: D:\Demo

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          09-08-2024    13:12           8397 brand-logo-2.svg
-a---          09-08-2024    13:12           8397 brand-logo.svg

THE “cd” COMMAND

The cd command is used to change the directory in terminal. Examples:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Moving to parent directory. i.e. from "C:\Users\kamal" to "C:\Users"
cd ..

# Moving to next two directories at once.
# i.e. from "C:\Users" to "C:\Users\kamal\appdata"
cd kamal\appdata

# Moving to another drive's directory using absolute path (full path).
# i.e. from "C:\Users\kamal\appdata" to "D:\Demo"
cd d:\demo

# Moving to another drive's directory using absolute path (full path).
# i.e. from "D:\demo" to "L:\Apps\"
cd L:\Apps\

THE “cp” COMMAND

This command can be used to copy files and/or folders from source to destination. The syntax is cp <source-path> <destination-path>. Examples:

1
2
3
4
5
# Copying one file from RandomData folder to D:\Demo
cp D:\RandomData\logo.png D:\demo

# Copying entire RandomData folder to D:\Demo
cp D:\RandomData D:\Demo\ -Recurse

Please note that -Recurse is required if you want to copy folder’s content as well. Not passing -Recurse will only copy folder, not it’s contents.

This post is licensed under CC BY 4.0 by the author.