Loading...
Skip to main content
Tutorial

Terminal and CLI Basics

· siimplelab
Terminal CLI
Photo by Gabrielle Orcutt on Unsplash

The terminal lets you control your computer with text commands. It’s faster and more powerful than GUI.

Install Ghostty

Ghostty is a fast, modern terminal app. Install it with Homebrew.

brew install --cask ghostty

Launch Ghostty after installation.

Check Current Location

pwd prints the current directory path.

pwd

Output example: /Users/username

List Files

ls shows files and folders in the current directory.

ls

Add options for more details.

ls -la
  • -l: Detailed info (permissions, size, date)
  • -a: Include hidden files

Change Directory

cd moves to a different directory.

cd Documents

Go to parent directory:

cd ..

Go to home directory:

cd ~

Create Directory

mkdir creates a new folder.

mkdir my-project

Create File

touch creates an empty file.

touch index.html

Delete Files/Folders

rm deletes files.

rm index.html

For folders, use -r option.

rm -r my-project

View File Contents

cat outputs file contents.

cat index.html

Copy Files/Folders

cp copies files.

cp index.html backup.html

Copy folders:

cp -r src dist

Move Files/Folders

mv moves or renames files.

mv old.html new.html

Clear Screen

clear clears the terminal screen.

clear

Or use Cmd + K (macOS).

Essential Commands

CommandDescription
pwdPrint current directory
lsList files
cdChange directory
mkdirCreate directory
touchCreate empty file
rmDelete file/folder
catOutput file contents
cpCopy
mvMove/rename
clearClear screen

These commands are all you need to start using the terminal.