Introduction to CLI

CLI and "terminal" overview

CLI and "terminal" overview

Framing the concepts

CLI (Command-Line Interface) is a text-based interface where users type commands to interact with the computer's operating system. Unlike graphical user interfaces (GUIs), the CLI requires users to type specific commands, which are then interpreted by the system to perform the requested actions.
"terminal" is an application, which acts as an interface to acces CLI. In "terminal" you type commands to perform actions on your computer. Instead of clicking, you type text and press Enter to execute actions (executing programs, managing files and directories, configuring system settings, and troubleshooting issues).
"terminal" allows users to execute commands directly, providing more control and flexibility compared to graphical user interfaces (GUIs). It supports a wide range of commands and utilities, making it suitable for both basic and advanced users.
"terminal" is commonly used by system administrators, developers, and power users for tasks such as system maintenance, batch processing, automation, package management and more.
"terminal" is a generic term used to describe command-line interfaces on various operating systems, including Windows, macOS, and Linux.
On Windows, examples of terminals are: Command Prompt and PowerShell
On Linux based OS: GNOME Terminal
On MacOS: Terminal

Command Prompt Basics

Command Prompt Basics

Opening Command Prompt

How to Open:
Press Windows + R, type cmd, and press Enter. Alternatively, search for "Command Prompt" in the Start menu.
This opens Command Prompt, starting in your user profile directory.

Current Working Directory (CWD)

The Current Working Directory is your active directory in the Command Prompt, acting as the reference point for all file and directory commands. It determines the context for executing commands and scripts.
Think of it as your home base. If you tell your computer to do something, it starts here and looks around in this spot
If you're in a folder named "Music" and look for a file, your computer only searches in "Music," not the whole computer
Example Scenario:
If your CWD is C:\Users\YourUsername\Documents and you run a command like dir Projects, it will list contents of C:\Users\YourUsername\Documents\Projects.
Viewing Current Directory: Type cd without arguments to see CWD:

                # Assuming CWD is C:\Users\UserName
                cd
                # Output: C:\Users\UserName
            
Best Practices:
Always verify your CWD with cd before executing commands to avoid unintended consequences, such as file deletions or incorrect script executions.

Viewing Folder Contents

Type dir to list all the files and folders within your current directory.
This command provides information like file size and the date last modified.
To view hidden files and folders you can use dir /a

                # Assuming CWD is C:\Users\UserName\Documents
                dir /a
                # Output:
                Volume in drive C has no label.
                Volume Serial Number is 1234-5678

                Directory of C:\Users\UserName\Documents

                02/15/2024  10:00 AM    <DIR>          .
                02/15/2024  10:00 AM    <DIR>          ..
                02/15/2024  10:00 AM    <DIR>          Projects
                02/15/2024  10:00 AM    <DIR>          Reports
                02/15/2024  10:00 AM    <DIR>          Presentations
                02/15/2024  10:00 AM    <DIR>          .hidden_folder
                            0 File(s)              0 bytes
                            6 Dir(s)  100,000,000,000 bytes free
            

Navigating Through Folders

Changing Directories: Use cd [FolderName] to move into a specific folder.

                # Assuming CWD is C:\Users\UserName
                cd Documents
                # New CWD: C:\Users\UserName\Documents
            
If you want to move to a folder deep within several layers of directories, you can chain them together with backslashes.

                # Assuming CWD is C:\Users\UserName
                cd Documents\Projects\Cources
                # New CWD: C:\Users\UserName\Documents\Projects\Cources
            
Going Up: type cd .. to move up one directory level. This command takes you to the parent directory of your current location.

                # Assuming CWD is C:\Users\UserName\Documents
                cd ..
                # New CWD: C:\Users\UserName
            
You can move several levels up by chaining .. with backslashes.

                # Assuming CWD is C:\Users\UserName\Documents
                cd ..\..
                # New CWD: C:\Users
            

These slides are based on

customised version of

Hakimel's reveal.js

framework