terminal
A quick reference to common terminal commands.
Navigation
Moving around the file system.
pwd
Print working directory (shows your current location).
pwd
cd [directory]
Change directory.
cd Documents
ls
List files and directories.
ls
ls -l
List files and directories with details.
ls -l
ls -a
List all files and directories (including hidden ones).
ls -a
cd ..
Go up one directory.
cd ..
cd ~
Go to your home directory.
cd ~
File Manipulation
Creating, moving, and deleting files and directories.
touch [file]
Create an empty file.
touch myfile.txt
mkdir [directory]
Create a new directory.
mkdir mydirectory
cp [source] [destination]
Copy a file or directory.
cp myfile.txt mycopy.txt
mv [source] [destination]
Move or rename a file or directory.
mv myfile.txt newlocation/myfile.txt
rm [file]
Remove a file.
rm myfile.txt
rm -r [directory]
Remove a directory and its contents (recursive).
rm -r mydirectory
rm -f [file]
Force remove a file (use with caution!).
rm -f myfile.txt
rm -rf [directory]
Force remove a directory and its contents (use with extreme caution!).
rm -rf mydirectory
Viewing Files
Displaying the contents of files.
cat [file]
Display the contents of a file.
cat myfile.txt
less [file]
View a file one page at a time (use space to scroll, q to quit).
less myfile.txt
head [file]
Display the first few lines of a file.
head myfile.txt
tail [file]
Display the last few lines of a file.
tail myfile.txt
nano [file]
Open a file in the nano text editor.
nano myfile.txt
vi/vim [file]
Open a file in the vi/vim text editor.
vi myfile.txt
Searching
Finding files and content.
find [directory] [options] [expression]
Find files and directories.
find . -name "myfile.txt"
grep [pattern] [file]
Search for a pattern in a file.
grep "hello" myfile.txt
which [command]
Show the location of a command.
which ls
System Information
Getting information about the system.
uname -a
Display system information.
uname -a
df -h
Display disk space usage.
df -h
du -sh [directory]
Display directory size.
du -sh Documents
top
Display running processes.
top
ps aux
List all running processes.
ps aux
Networking
Commands related to network operations.
ping [host]
Check network connectivity to a host.
ping google.com
ifconfig
Display network interface information (macOS/Linux).
ifconfig
ipconfig
Display network interface information (Windows).
ipconfig
netstat
Display network connections.
netstat
curl [url]
Transfer data from or to a server.
curl https://www.example.com
wget [url]
Download a file from a URL.
wget https://www.example.com/file.zip
Package Management (macOS - Homebrew)
Managing software packages with Homebrew.
brew install [package]
Install a package.
brew install wget
brew uninstall [package]
Uninstall a package.
brew uninstall wget
brew update
Update Homebrew and its packages.
brew update
brew search [package]
Search for a package.
brew search wget
brew list
List installed packages.
brew list