Back to Cheatsheets
Terminal & Git

Terminal Commands

Essential CLI commands for navigation, file management, and processes

Navigation

6 items
CommandDescription
pwd
Print working directory
Example:/Users/dev/projects
cd <dir>
Change directory
Example:cd ~/projects
cd ..
Go up one level
Example:cd ../parent-folder
cd ~
Go to home directory
Example:cd ~ && pwd
ls
List directory contents
Example:ls src/
ls -la
List all files with details
Example:ls -la ~/.config

File Operations

8 items
CommandDescription
touch <file>
Create empty file
Example:touch index.js
mkdir <dir>
Create directory
Example:mkdir components
mkdir -p <path>
Create nested directories
Example:mkdir -p src/lib/utils
cp <src> <dest>
Copy file
Example:cp file.txt backup.txt
cp -r <dir> <dest>
Copy directory recursively
Example:cp -r src/ dist/
mv <src> <dest>
Move or rename
Example:mv old.js new.js
rm <file>
Remove file
Example:rm temp.log
rm -rf <dir>
Remove directory recursively (careful!)
Example:rm -rf node_modules

Reading Files

5 items
CommandDescription
cat <file>
Display file contents
Example:cat package.json
head <file>
Show first 10 lines
Example:head -n 20 README.md
tail <file>
Show last 10 lines
Example:tail -n 50 app.log
tail -f <file>
Follow file updates (logs)
Example:tail -f server.log
less <file>
View file with pagination
Example:less large-file.txt

Search & Find

4 items
CommandDescription
find . -name "*.js"
Find files by name
Example:find src/ -name "*.tsx"
grep "text" <file>
Search text in file
Example:grep "TODO" app.js
grep -r "text" .
Search recursively in directory
Example:grep -r "console.log" src/
which <cmd>
Find command location
Example:which node

Permissions

3 items
CommandDescription
chmod +x <file>
Make file executable
Example:chmod +x deploy.sh
chmod 755 <file>
Set read/write/execute permissions
Example:chmod 755 script.sh
chown user:group <file>
Change file owner
Example:chown www-data:www-data index.html