Skip to content
Latest: Publish JavaScript Packages to NPM Like a Pro!

Command Line Cheat Sheet – CLI Commands for Easy Reference

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.

Windows PowerShell
CLI

The Windows PowerShell command-line interface

A terminal’s command comprises three components: a utility, a flag, and an argument.

Here is the syntax:

Terminal window
utility -flag argument

Note the following:

  • A utility tells the computer the function you want it to run. Many CLI commands require only a utility.
  • A flag alters the utility’s mode of operation. In other words, we use flags to specify preferences on how computers should run the utility command.
  • Flags always start with one or two hyphens (-).
  • Flags are typically written after the utility command and before an argument.
  • An argument says the exact action the utility command should perform.

Let’s now see some of the widely used commands.

Below are the commands for creating, accessing, and deleting directories on your system.

DescriptionCommand
Check the current working directory’s path
Terminal window
pwd
Change directory from the current working directory to another-directory
Terminal window
cd another-directory
Change directory from the current working directory to its parent directory
Terminal window
cd ..
Copy directory1 into directory2
Terminal window
cp -r directory1 directory2
Remove a directory permanently from your system
Terminal window
rm -r name-of-directory-to-delete
Remove a directory permanently and forcefully from your system
Terminal window
rm -rf name-of-directory-to-delete-forcefully
Rename a directory
Terminal window
mv current-directory-name/ new-directory-name/
List out the current directory’s content
Terminal window
ls
List out the current directory’s content using the long listing format
Terminal window
ls -l
List out all the current directory’s content—including all hidden content
Terminal window
ls -a
List out all the current directory’s content using the long listing format. Also, include all hidden content
Terminal window
ls -la
Make a new directory
Terminal window
mkdir name-of-new-directory

Below are the commands for creating, accessing, and deleting your system’s files.

DescriptionCommand
Convert Word to Markdown with Pandoc
Terminal window
pandoc word-document.docx -o new-file-name.md --wrap=none
Convert Word to Markua with Pandoc
Terminal window
pandoc word-document.docx -t markua -o new-file-name.txt --wrap=none
Create a new file
Terminal window
touch name-of-new-file
Create test1.md file
Terminal window
touch test1.md
Create test1.md, test2.md, test3.md, and test4.md files
Terminal window
touch test{1..4}.md
Copy a file into a specific directory
Terminal window
cp file-to-copy directory-to-copy-file-into
Move a file into a new directory
Terminal window
mv file-to-move directory-to-move-file-into
Open a file with its default app
Terminal window
start filename
Open a file with VSCode
Terminal window
code filename
Print a file’s content on the terminal
Terminal window
cat filename
Print a file’s content in parts on the terminal
Terminal window
less filename
Print the first ten (10) lines of a specific file on the terminal
Terminal window
head filename
Print the last ten (10) lines of a specific file on the terminal
Terminal window
tail filename
Reduce image size from original width to 7px wide while retaining the original aspect ratio
Terminal window
ffmpeg -i image_name.jpg -vf scale=7:-1 image_name_tiny.jpg
Remove a file permanently from your system
Terminal window
rm name-of-file-to-delete
Remove a file permanently and forcefully from your system
Terminal window
rm -f name-of-file-to-delete-forcefully
Rename a file
Terminal window
mv current-file-name new-file-name

Below are the commands for downloading and testing network resources.

DescriptionCommand
Download a file
Terminal window
curl -O url-of-the-file
Test a network host’s reachability
Terminal window
ping domain-name.com

Below are the commands for displaying your system’s information.

DescriptionCommand
Display the current date and time
Terminal window
date
Display your CPU’s information
Terminal window
cat /proc/cpuinfo
Display your memory’s information
Terminal window
cat /proc/meminfo
Display your system’s disks usage information
Terminal window
df
Display your current directory’s space usage information
Terminal window
du
Clear your terminal’s content
Terminal window
clear