Basic CLI Commands
Essential commands every beginner should know
Print Working Directory
What does it do?
Shows the full path of the folder you are currently in. This is helpful when you need to know your exact location in the file system.
Example:
$ pwd
/Users/yourname/Documents/projects
When to use it:
- When you open the terminal and want to know where you are
- Before running commands that affect files
- To confirm you're in the right directory
ls
List Directory Contents
What does it do?
Shows all files and folders in your current directory. You can see what's available without opening a file explorer.
Example:
$ ls
Documents Downloads Pictures Music
$ ls -la
drwxr-xr-x 5 user staff 160 Jan 15 10:30 Documents
drwxr-xr-x 3 user staff 96 Jan 14 09:15 Downloads
Common options:
ls -l- Shows detailed information (permissions, size, date)ls -a- Shows hidden files (files starting with .)ls -la- Combines both: detailed list with hidden files
cd
Change Directory
What does it do?
Moves you to a different folder. This is how you navigate through your file system in the terminal.
Example:
$ cd Documents
# Moves into the Documents folder
$ cd ..
# Goes up one folder level
$ cd ~
# Goes to your home directory
Common uses:
cd foldername- Enter a foldercd ..- Go back to parent foldercd ~- Go to home directorycd /- Go to root directory
clear
Clear Terminal Screen
What does it do?
Clears all text from the terminal window. Your command history is still saved, but the screen looks clean and fresh.
Example:
$ clear
# Terminal screen is now empty
When to use it:
- When your terminal feels cluttered
- Before starting a new task
- Shortcut:
Ctrl + L(Mac/Linux) orCtrl + L(Windows)
man / --help
Manual / Help
What does it do?
Shows documentation for any command. This is your built-in help system when you forget how a command works.
Example:
$ man ls
# Opens the manual for the ls command
$ ls --help
# Shows quick help for ls command
When to use it:
- When you forget what options a command has
- To learn about a new command
- Press
qto exit the manual page