--- title: pwd — Linux basic command date: 2026-10-19 time: 12:00 model: admin category: programs author_type: human summary: Outputs the full path of the current working directory. tags: program, Basic Linux commands, pwd --- Command that prints the full path of the current working directory. ## Basic Information | Command Name | pwd (print working directory) | | --- | --- | | One-Line Summary | Command that prints the full path of the current working directory. | | Provided By | Bash/Zsh shell built-in command (pre-installed in all Linux distributions) | | Official Documentation | https://man7.org/linux/man-pages/man1/pwd.1p.html | | Supported Operating Systems | Linux, macOS, BSD, WSL (shell built-in) | | Installation Status | Pre-installed (no separate installation required) | | Category | Linux basic command (tags: current location, directory, Linux, basic) | ## What is this command? pwd is an abbreviation for print working directory, and it is a command that prints the full absolute path of the current working directory to the screen. It is used when the path is not displayed in the shell prompt or when checking the current location in a script. As a shell built-in command, it is very fast and allows you to accurately know which directory you are in. ## What problems does it solve? - Check the current working directory. - Check the current location in scripts. - Determine the current location when the path becomes too deep. - Convert relative paths to absolute paths. ## Main Features ### Print Absolute Path Prints the full absolute path of the current directory. - **Usage Situation**: When you need to know the exact current location. - **Result Obtained**: The full path is displayed, like /home/user/project. - **Limitations**: It may not be used frequently beyond simple verification. ### Synchronization with Shell Variable PWD Returns the same value as the $PWD variable. - **Usage Situation**: Used in scripts that utilize shell variables. - **Result Obtained**: You can obtain consistent path information. - **Limitations**: Implementation may differ in some shells. ### Logical and Physical Paths It can show the actual path following symbolic links. - **Usage Situation**: When checking the actual location in environments with many symbolic links. - **Result Obtained**: You can distinguish between physical and logical paths. - **Limitations**: The -P option is only supported in some shells. ## Installation and Execution ### Verify Pre-installation It is built into all shells. ``` type pwd # pwd is a shell builtin ``` ### Display Path in Shell Prompt Configure the prompt to display the current path. ``` # Add to ~/.bashrc export PS1='\u@\h:\w\$ ' # Apply source ~/.bashrc # Now the path is displayed in the prompt ``` ## Practical Usage Examples ### Basic Usage Check the current directory. ``` # Print current path pwd # Result: /home/user/projects # Check in prompt $ pwd /home/user/projects ``` ### Usage in Scripts Check the current location in shell scripts. ``` #!/bin/bash # Check current location in script echo "Current location: $(pwd)" # Save absolute path CURRENT_DIR=$(pwd) echo "Working directory: $CURRENT_DIR" ``` ### Check Symbolic Link Path Check the physical path. ``` # Logical path (follows symbolic links) pwd # Physical path (actual path) pwd -P # Example: # pwd -> /home/user/link # pwd -P -> /opt/real/path ``` --- Source (HTML): https://games.aidebatehub.com/programs/linux/basics/pwd.html This file is an auto-generated Markdown twin of the DevHub document.