An Introduction to the Command Line
Navigating the Digital World
Chuck Nelson
September 10, 2025
1 Navigating the Digital World: An Introduction to the Command Line

As an IT student, you’ll find that while graphical user interfaces (GUIs) are great for everyday tasks, they’re not always the best tool for the job. The command line (also known as the command-line interface or CLI) is a text-based interface used to interact with a computer’s operating system. It may seem intimidating at first, but mastering it is an essential skill for any IT professional.
1.1 Why the Command Line is a Necessary Skill for IT Professionals
The command line is not an outdated technology; it’s a powerful tool for efficiency and automation. Here’s why it’s so critical in the professional world:
Efficiency: Instead of clicking through multiple menus and windows, you can perform complex operations on many files with a single command. This speed is invaluable for system administrators and developers.
Automation: Repetitive tasks, like daily backups or software deployments, can be scripted using command-line commands. This saves time and reduces the risk of human error.
Remote Management: When managing servers and cloud services (like those from Amazon Web Services or Microsoft Azure), you’ll often only have a command-line interface. There’s no GUI to click on, so knowing the commands is the only way to get things done.
Troubleshooting: The command line provides a deeper level of insight into a system’s inner workings. You can view logs, diagnose network issues, and check system configurations, all of which are crucial for effective troubleshooting.
1.2 Terminal Applications, Shells, and Command Line Environments
To use the command line, you need a terminal application. This is the program you run to access a shell. The shell is a program that interprets the commands you type and passes them to the operating system.
While the fundamental principles are similar, the commands themselves can differ between operating systems.
Linux and macOS are both based on UNIX, so their command-line environments and many core commands are very similar. The most common shell is Bash (Bourne Again Shell).
Windows is built on a different architecture. Its modern shell, PowerShell, offers powerful object-oriented features. The traditional shell, Command Prompt (CMD), is a legacy environment.
1.3 The Generic Structure of a Command
Most command-line commands follow a similar structure: command_name [flags] [arguments].
command_name: This is the name of the program you want to run (e.g.,ls,cd,copy).[flags]: Also known as options or switches, these are used to modify a command’s behavior. They’re often preceded by a hyphen (-) or double hyphen (--). For example, inls -l, the-lflag tells thelscommand to list files in a long format, showing more details like permissions and ownership.[arguments]: These are the inputs the command acts upon. They can be file names, directory paths, or other data. For example, incp file.txt new_location/,file.txtandnew_location/are the arguments. Both flags and arguments are optional, and their order can sometimes matter depending on the command.
Globbing and Handling Spaces
Globbing (Wildcards): Globbing is how a shell expands a pattern (wildcards) into a list of file names. The most common wildcards are:
*: Matches zero or more characters. For example,ls *.txtwill list all files in the current directory ending with.txt.?: Matches a single character. For example,ls file_?.logwould matchfile_A.logbut notfile_AB.log.
Handling Spaces: Spaces separate the command, flags, and arguments. To use a file or directory name with a space, you must enclose it in double quotes (
" ") or escape the space with a backslash (\). For example, to handle a file namedmy file.txt:touch "my file.txt"(using double quotes)touch my\ file.txt(using a backslash)
Getting Help: -h, --help, and man pages
When you don’t know the proper syntax for a command, there are several ways to get help directly from the terminal.
Simple Help: Most commands support a short help flag, typically
-hor--help. This will print a brief usage summary and common flags directly to your terminal. For example:ls --helpManual Pages (
man): For more comprehensive documentation, UNIX-based systems (Linux and macOS) have manual pages, ormanpages. These are detailed documents for each command. To view amanpage, simply typemanfollowed by the command name. For example:man ls
1.4 Basic Command Line Tasks: A Practical Guide
This guide will walk you through some fundamental tasks in each of the three major operating systems.
These commands work in PowerShell and Command Prompt (CMD).
Directory Navigation
| Task | PowerShell Command | CMD Command |
|---|---|---|
| Print current directory | Get-Location (or pwd) |
cd |
| List files/folders | Get-ChildItem (or ls) |
dir |
| Change directory | Set-Location (or cd) [directory_name] |
cd [directory_name] |
| Go up one directory | Set-Location .. (or cd ..) |
cd .. |
| Go to user’s home | Set-Location ~ (or cd ~) |
%userprofile% |
File Handling
| Task | PowerShell Command | CMD Command |
|---|---|---|
| Create empty file | New-Item -ItemType File -Name [file_name] |
echo. > [file_name] |
| Create new directory | New-Item -ItemType Directory -Name [directory_name] |
mkdir [directory_name] |
| Copy a file | Copy-Item [source_file] [destination_file] |
copy [source_file] [destination_file] |
| Move/rename a file | Move-Item [old_name] [new_name] |
move [old_name] [new_name] |
| Remove a file | Remove-Item [file_name] |
del [file_name] |
| Remove directory/contents | Remove-Item [directory_name] -Recurse |
rmdir /s [directory_name] |
Text File Editing
PowerShell:
notepad [file_name]CMD:
notepad [file_name]
Environment Variables
PowerShell:
Get-ChildItem Env:orGet-Item Env:[variable_name](e.g.,Get-Item Env:Path)CMD:
setorecho %variable_name%(e.g.,echo %PATH%)
Permissions
Windows uses a different, more complex permission system (NTFS). The command for viewing permissions is icacls, which can be used in both shells.
icacls [file_name]
These commands work for both Linux and macOS.
Directory Navigation
Print current working directory:
pwdList files and folders:
lsList all files and folders (including hidden ones):
ls -aChange directory:
cd [directory_name](e.g.,cd Documents)Go up one directory:
cd ..Go back to your home directory:
cd ~
File Handling
Create an empty file:
touch [file_name]Create a new directory:
mkdir [directory_name]Copy a file:
cp [source_file] [destination_file]Move or rename a file:
mv [old_name] [new_name]Remove a file:
rm [file_name]Remove a directory and its contents:
rm -r [directory_name]
Text File Editing
Linux and macOS have powerful command-line text editors. A beginner-friendly option is Nano.
Open a file for editing:
nano [file_name]Use the on-screen instructions to navigate and edit.
To save and exit, press
Ctrl + X, thenYto confirm, andEnter.
Environment Variables
An environment variable is a dynamic named value that affects the way running processes behave. The most important one is the $PATH.
What is the
$PATHThe$PATHvariable is a list of directories where your shell looks for executable programs. When you type a command likels, the shell searches through the directories listed in your$PATHto find thelsprogram and run it.View your PATH:
echo $PATHView all environment variables:
env
Permissions (Linux & macOS)
UNIX-based systems use a robust permission system to control who can read, write, or execute files.
View permissions:
ls -lThe output will look something like this:
-rwxrw-r-- 1 user group 1024 Jan 1 12:00 file.txtThe first character (
-ord) indicates a file or directory.The next three sets of
rwxcharacters represent read (r), write (w), and execute (x) permissions for the user, group, and others, respectively.
Change permissions:
chmod [permissions] [file_name](e.g.,chmod 755 script.shto give the owner read, write, and execute permissions, and the group and others read and execute).