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.
Command line interfaces are sometimes called terminals.
Syntax of a Terminal's Command
A terminal's command comprises three components: a utility, a flag, and an argument.
Here is the syntax:
utility -flag argument
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.
Directories are sometimes called folders.
Description | Command |
---|---|
Check the current working directory's path |
|
Change directory from the current working directory to |
|
Change directory from the current working directory to its parent directory |
note The whitespace between |
Copy |
note The duplicated directory will overwrite an existing directory with the same name. |
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 |
|
Copy a file into a specific directory |
note The duplicated file will overwrite an existing file with the same name. |
Display all the content in a specific file |
|
Display some of the content in a specific file |
CodeSweetly TIP
|
Display the first ten (10) lines of a specific file |
|
Display the last ten (10) lines of a specific file |
|
Move a file into a new directory |
note The moved file will overwrite an existing file with the same name. |
Remove a file permanently from your system |
|
Remove a file permanently and forcefully from your system |
|
Rename a file |
|
Networking Commands
Below are the commands for downloading and testing network resources.
Description | Command |
---|---|
Download a file |
note The -O flag must be in uppercase. |
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 |
|