Command Line Cheat Sheet – CLI Commands for Easy Reference
What Is a Command Line Interface?
A command line interface (CLI) is a computer’s text interface allowing you to type commands for the computer to run.
Below is an image of the Windows PowerShell terminal application.
Syntax of a Terminal’s Command
A terminal’s command comprises three components: a utility, a flag, and an argument.
Here is the syntax:
Note the following:
-
A
utility
tells the computer the function you want it to run. Many CLI commands require only autility
. -
A
flag
alters theutility
’s mode of operation. In other words, we use flags to specify preferences on how computers should run theutility
command. -
Flags always start with one or two hyphens (
-
). -
Flags are typically written after the
utility
command and before anargument
. -
An
argument
says the exact action theutility
command should perform.
Let’s now see some of the widely used commands.
Directory Management Commands
Below are the commands for creating, accessing, and deleting directories on your system.
Description | Command |
---|---|
Check the current working directory’s path | |
Change directory from the current working directory to another-directory | |
Change directory from the current working directory to its parent directory | |
Copy directory1 into directory2 | |
Remove a directory permanently from your system | |
Remove a directory permanently and forcefully from your system | |
List out the current directory’s content | |
List out the current directory’s content using the long listing format | |
List out all the current directory’s content—including all hidden content | |
List out all the current directory’s content using the long listing format. Also, include all hidden content | |
Make a new directory |
Files Management Commands
Below are the commands for creating, accessing, and deleting your system’s files.
Description | Command |
---|---|
Create a new file | |
Create test1.md file | |
Create test1.md , test2.md , test3.md , and test4.md files | |
Copy a file into a specific directory | |
Move a file into a new directory | |
Open a file with its default app | |
Open a file with VSCode | |
Print a file’s content on the terminal | |
Print a file’s content in parts on the terminal | |
Print the first ten (10) lines of a specific file on the terminal | |
Print the last ten (10) lines of a specific file on the terminal | |
Remove a file permanently from your system | |
Remove a file permanently and forcefully from your system | |
Rename a file |
Learn CSS Grid with Images
Networking Commands
Below are the commands for downloading and testing network resources.
Description | Command |
---|---|
Download a file | |
Test a network host’s reachability |
System Information Commands
Below are the commands for displaying your system’s information.
Description | Command |
---|---|
Display the current date and time | |
Display your CPU’s information | |
Display your memory’s information | |
Display your system’s disks usage information | |
Display your current directory’s space usage information | |
Clear your terminal’s content |