Terminal and CLI Basics
· siimplelab
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
| Command | Description |
|---|---|
pwd | Print current directory |
ls | List files |
cd | Change directory |
mkdir | Create directory |
touch | Create empty file |
rm | Delete file/folder |
cat | Output file contents |
cp | Copy |
mv | Move/rename |
clear | Clear screen |
These commands are all you need to start using the terminal.