Pwd Explained

pwd
Author:AT&T Bell Laboratories
Developer:Various open-source and commercial developers
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

In Unix-like and some other operating systems, the '''pwd''' command (print working directory)[1] [2] [3] writes the full pathname of the current working directory to the standard output.[4] [5] [6] [7] [8] [9] [10]

Implementations

Multics had a pwd command (which was a short name of the print_wdir command)[11] from which the Unix pwd command originated.[12] The command is a shell builtin in most Unix shells such as Bourne shell, ash, bash, ksh, and zsh. It can be implemented easily with the POSIX C functions getcwd or getwd.

It is also available in the operating systems SpartaDOS X,[13] PANOS,[14] and KolibriOS.[15] The equivalent on DOS ([[COMMAND.COM]]) and Microsoft Windows ([[cmd.exe]]) is the [[cd (command)|cd]] command with no arguments. Windows PowerShell provides the equivalent Get-Location cmdlet with the standard aliases gl and pwd.On Windows CE 5.0, the cmd.exe Command Processor Shell includes the pwd command.[16]

as found on Unix systems 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 of pwd bundled in GNU coreutils was written by Jim Meyering.

The numerical computing environments MATLAB and GNU Octave include a pwd function with similar functionality.[17] [18] The OpenVMS equivalent is show default.

Command Explanation
pwd Display the current working directory. Example: /home/foobar
pwd -P Display the current working directory physical path - without symbolic link name, if any. Example: If standing in a dir /home/symlinked, that is a symlink to /home/realdir, this would show /home/realdir
pwd -L Display the current working directory logical path - with symbolic link name, if any. Example: If standing in a dir /home/symlinked, that is a symlink to /home/realdir, this would show /home/symlinked

Note: POSIX requires that the default behavior be as if the -L switch were provided.

Working directory shell variables

POSIX shells set the following environment variables while using the cd command:[19]

OLDPWD : The previous working directory (as set by the cd command).
  • PWD : The current working directory (as set by the cd command).
  • See also

    Further reading

    Notes and References

    1. Web site: pwd(1) [minix man page]]. www.unix.com.
    2. Web site: pwd - print name of current/working directory - man page. www.mankier.com.
    3. Web site: GNU Coreutils. www.gnu.org.
    4. Book: Unix Time-Sharing System: Unix Programmer's Manual. 7th. 1. January 1979. Bell labs. 142. https://web.archive.org/web/20050520231659/http://cm.bell-labs.com/7thEdMan/v7vol1.pdf. 2005-05-20.
    5. Web site: pwd(1) [plan9 man page]]. www.unix.com.
    6. Web site: pwd. pubs.opengroup.org.
    7. Web site: pwd(1) [osf1 man page]]. www.unix.com.
    8. Web site: Apple OS X MAN page.
    9. Web site: pwd(1) - OpenBSD manual pages. man.openbsd.org.
    10. Web site: pwd(1) [opensolaris man page]]. www.unix.com.
    11. Web site: working_dir, wd, print_wdir, pwd (Multics help segment) . MIT . 7 March 2020.
    12. Web site: Van Vleck . Tom . Unix and Multics . Multicians.org . 7 March 2020.
    13. Web site: SpartaDOS X 4.48 User Guide.
    14. Web site: Chris's Acorns: Panos. chrisacorns.computinghistory.org.uk.
    15. Web site: Shell - KolibriOS wiki. wiki.kolibrios.org.
    16. Web site: Command Processor Commands (Windows CE 5.0). docs.microsoft.com.
    17. Web site: Identify current folder - MATLAB pwd. www.mathworks.com.
    18. Web site: Function Reference: pwd. octave.sourceforge.io.
    19. Web site: cd. pubs.opengroup.org.