A terminal prompt shows where you can enter shell commands. The current directory determines how relative file names are interpreted.
Understanding the Concept
On Windows, PowerShell prompts commonly show a folder path. On macOS or Linux, Terminal may show a username, hostname, and folder. The prompt itself is not part of a command to type. Use pwd in PowerShell or Unix shells to display the current directory; Windows Command Prompt uses cd without arguments. Change directories with cd folder_name. When you run python greeting.py, Python looks for greeting.py relative to the shell’s current directory unless you provide another path.
When and Why You Would Use This
Paths containing spaces often need quotes. You can also run a script using its absolute path, although files opened with relative paths inside the script still depend on the working directory.
Practical Example
pwd
cd PythonProjects
python greeting.py
Understanding the Example
This is a shell-oriented example and the commands only work when the named directories and file exist. pwd is available in PowerShell and typical Unix shells. On Windows Command Prompt, use cd to display the current directory instead.
Try It Yourself
Open a terminal, identify your current directory, navigate into a practice project, and list its files.
Common Beginner Mistakes
- Copying the $ or > prompt symbol as if it were part of a command.
- Running a file from a directory that does not contain it.
- Assuming the current directory and the script file’s directory are always the same.
Key Takeaways
- The prompt is an indicator that the shell is ready.
- Working directory controls relative command paths.
- Use pwd/cd and quoted paths to navigate reliably.