Pwd

Shell command that reports the working directory


title: "Pwd" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["multics-commands", "unix-sus2008-utilities", "plan-9-commands", "inferno-(operating-system)-commands", "ibm-i-qshell-commands", "file-system-directories"] description: "Shell command that reports the working directory" topic_path: "technology/operating-systems" source: "https://en.wikipedia.org/wiki/Pwd" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0

::summary Shell command that reports the working directory ::

::data[format=table title="Infobox software"]

FieldValue
namepwd
screenshotPwdkommando.png
captionThe pwd command
authorAT&T Bell Laboratories
developerVarious open-source and commercial developers
released
programming languageC
operating systemMultics, Unix, Unix-like, V, Plan 9, Inferno, SpartaDOS X, PANOS, Windows CE, KolibriOS
platformCross-platform
genreCommand
licensecoreutils: GPLv3+
Plan 9: MIT License
::

| name = pwd | logo = | screenshot = Pwdkommando.png | screenshot size = | caption = The pwd command | author = AT&T Bell Laboratories | developer = Various open-source and commercial developers | released = | latest release version = | latest release date = | programming language = C | operating system = Multics, Unix, Unix-like, V, Plan 9, Inferno, SpartaDOS X, PANOS, Windows CE, KolibriOS | platform = Cross-platform | genre = Command | license = coreutils: GPLv3+ Plan 9: MIT License | website = **pwd** (print working directory) is a shell command that reports the working directory path to standard output.

Although often associated with Unix, its predecessor Multics had a pwd command (which was a short name of the print_wdir command) from which the Unix command originated. The command is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the Single Unix Specification. It appeared in Version 5 Unix. The version bundled in GNU Core Utilities was written by Jim Meyering.

The command is available in other shells and operating systems including SpartaDOS X, PANOS, and KolibriOS. PowerShell provides as an alias for the cmdlet Get-Location. An equivalent command in COMMAND.COM and Command Prompt is the [cd](cd-command) command with no arguments. On Windows CE 5.0, cmd.exe includes a pwd command. The OpenVMS equivalent is show default.

The numerical computing environments MATLAB and GNU Octave include a pwd function with similar functionality.

The command is implemented as a shell builtin in many Unix shells including sh, ash, bash, ksh, and zsh. It can be implemented with the POSIX getcwd() or getwd() functions.

Examples

The following examples are based on a typical Unix-based implementation.

With no arguments, the command writes the working directory path to the terminal:

$ cd /home/example $ pwd /home/example

Display the working directory without any symbolic link info. If at a directory /home/symlinked that is a symlink to /home/realdir:

$ cd /home/symlinked $ pwd -P /home/realdir

Display the working directory with symbolic link info. Note: POSIX requires that the default behavior be as if the -L switch were provided.

$ pwd -L /home/symlinked

Shell variables

POSIX shells set the following environment variables while using the command:

; OLDPWD : The previous working directory ; PWD : The current working directory

References

References

  1. "pwd(1) [minix man page]".
  2. "pwd - print name of current/working directory - man page".
  3. "GNU Coreutils".
  4. (January 1979). "Unix Time-Sharing System: Unix Programmer's Manual". [[Bell labs]].
  5. "pwd(1) [plan9 man page]".
  6. "pwd".
  7. "pwd(1) [osf1 man page]".
  8. "Apple OS X MAN page".
  9. "pwd(1) - OpenBSD manual pages".
  10. "pwd(1) [opensolaris man page]".
  11. "working_dir, wd, print_wdir, pwd (Multics help segment)".
  12. "Unix and Multics".
  13. {{man. cu. wc. SUS
  14. {{man. 1. pwd. FreeBSD
  15. {{man. 1. pwd. Linux
  16. "SpartaDOS X 4.48 User Guide".
  17. "Chris's Acorns: Panos".
  18. "Shell - KolibriOS wiki".
  19. "Command Processor Commands (Windows CE 5.0)".
  20. "Identify current folder - MATLAB pwd".
  21. "Function Reference: pwd".
  22. "cd".

::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::

multics-commandsunix-sus2008-utilitiesplan-9-commandsinferno-(operating-system)-commandsibm-i-qshell-commandsfile-system-directories