0
0
Linux CLIscripting~10 mins

pwd (print working directory) in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - pwd (print working directory)
User types 'pwd'
Shell receives command
Shell executes pwd program
pwd reads current directory
pwd outputs directory path
Shell displays output to user
The shell runs the pwd command, which finds and prints the current directory path to the screen.
Execution Sample
Linux CLI
pwd
Prints the full path of the current working directory.
Execution Table
StepActionResultOutput
1User types 'pwd' and presses EnterShell receives command
2Shell runs pwd programpwd reads current directory path
3pwd outputs current directory pathOutput sent to shell/home/user/projects
4Shell displays outputUser sees current directory path/home/user/projects
5Command endsShell waits for next command
💡 pwd finishes after printing the current directory path
Variable Tracker
VariableStartAfter Step 2After Step 3Final
current_directoryundefined/home/user/projects/home/user/projects/home/user/projects
Key Moments - 2 Insights
Why does pwd print the full path instead of just the folder name?
pwd always prints the full absolute path to show exactly where you are in the system, as seen in execution_table step 3 where it reads and outputs the full path.
What happens if you run pwd in the root directory?
pwd will print '/', the root directory path, because it always shows the current directory, as shown in execution_table step 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what does pwd output at step 3?
A/usr/bin
Bpwd
C/home/user/projects
DNo output
💡 Hint
Check the 'Output' column in execution_table row for step 3
At which step does the shell display the current directory path to the user?
AStep 4
BStep 2
CStep 1
DStep 3
💡 Hint
Look at the 'Action' and 'Result' columns in execution_table for when output is shown to the user
If the current directory changes before running pwd, how would the output in step 3 change?
AIt would still show /home/user/projects
BIt would show the new current directory path
CIt would show an error
DIt would show the root directory '/'
💡 Hint
Refer to variable_tracker showing current_directory value at step 3
Concept Snapshot
pwd command prints the full path of your current directory.
Type pwd and press Enter.
Shell runs pwd, which reads and outputs the current directory.
Output helps you know exactly where you are in the system.
Useful before running other commands that depend on location.
Full Transcript
The pwd command in Linux prints the full path of the current working directory. When you type pwd and press Enter, the shell runs the pwd program. This program reads the current directory path from the system and outputs it. The shell then displays this path on the screen so you can see exactly where you are. For example, it might show /home/user/projects. This helps you keep track of your location in the file system before running other commands.