
a folder practice
༶•┈┈୨♡୧┈┈•༶
terminal intro
✧・゚: *✧・゚:*
a folder practice
༶•┈┈୨♡୧┈┈•༶
terminal intro
✧・゚: *✧・゚:*
Basics
Basics
# pwd - Print Working Directory (where am I?) pwd # Output: /Users/kay/Desktop # ls - List (what's here?) ls # Shows all visible files and folders # cd - Change Directory (go somewhere) cd Desktop cd .. # Go up one level cd # Go home # mkdir - Make Directory (create a folder) mkdir MyProject mkdir "My Project" # With spaces # touch - Create empty file touch notes.txt touch "my notes.txt" # With spaces # rm - Remove (delete) rm file.txt # Delete file rm -r MyFolder # Delete folder (-r for recursive)
Use the tab key!! It auto-completes names AND handles spaces for you:
Use the tab key!! It auto-completes names AND handles spaces for you:
# Instead of typing the full name: cd Documents # Just type a few letters + Tab: cd Doc[TAB] # Auto-completes to: cd Documents/ # With spaces, Tab adds escapes: cd My[TAB] # Auto-completes to: cd My\ Project/ # Multiple matches? Press Tab twice: cd D[TAB][TAB] # Shows: Desktop/ Documents/ Downloads/ # Tab works with commands too: mkd[TAB] # Auto-completes to: mkdir
How to handle spaces in the path/folder name in Terminal
How to handle spaces in the path/folder name in Terminal
# If your file path or file name contains spaces, you need to add quotes to wrap it. "this is a file name with spaces" ~/Desktop/"this is a file name with spaces" # Or you can type \+space to represent the space
Path
Path
# Absolute path (full address from root) /Users/kay/Desktop/MyProject/file.txt # Relative path (from current location) MyProject/file.txt # Child folder ../Documents/file.txt # Sibling folder ../../file.txt # Parent's parent # Home path (shortcut) ~/Desktop/MyProject/file.txt # Or you can drag the file to the terminal to get its path
Tips for beginners
Tips for beginners
Tab is your friend - Use it constantly
pwd when lost - Shows where you are
ls before acting - See what's there first
Quotes for spaces - When in doubt, use quotes
cd alone goes home - Easy reset
Careful with rm - No trash can in Terminal!
Drag from Finder - Auto-fills paths correctly
Tab is your friend - Use it constantly
pwd when lost - Shows where you are
ls before acting - See what's there first
Quotes for spaces - When in doubt, use quotes
cd alone goes home - Easy reset
Careful with rm - No trash can in Terminal!
Drag from Finder - Auto-fills paths correctly