pwd — check current path
Print the absolute path of the current working directory. Usage example for setting a base path in a script and execution screen.
💬 "pwd command"
- Concept: Short for Print Working Directory, it outputs the absolute path of the directory you are currently in.
- Output structure: It prints only a single line: the path. No other information.
- Practical recommended output: In deployment scripts, running
pwdaftercd "$(dirname "$0")"and logging the base path can reduce incidents. - Left column: Not applicable — the output is always a single absolute path starting from root (
/). - Right column: Not applicable — if you need to know the symbolic link path, use
pwd -Pto check the actual path.
Three essential command combinations
pwd— check the absolute path of the current locationpwd -P— resolve symbolic links and check the actual pathcd /var/log && pwd— verify the location after moving
Here are some useful tips as well.
- Printing
pwdon the first line of a script makes troubleshooting easier. - When the path is ambiguous, using
ls -altogether withpwdis more reliable.
💬 "Give me an example I can use right away in the terminal"
Scenario: preventing a deployment script from running in the wrong folder.
Step 1: Record the current location
Check the path at the script's starting point.
pwd
Step 2: Move to the working folder
Move to the deployment target folder.
cd /var/www/app
Step 3: Verify the move result
Print the path again to confirm that you actually moved.
pwd && ls -al
Actual execution screen
An example screen of checking the current path with pwd.
!pwd command execution result: absolute path of the current working directory
Actual production server
Source (HTML): https://games.aidebatehub.com/programs/linux/filesystem/pwd.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments