Pwd

Last updated
pwd
Pwdkommando.png
The pwd command
Original author(s) AT&T Bell Laboratories
Developer(s) Various open-source and commercial developers
Initial releaseJune 1974;48 years ago (1974-06)
Written in C
Operating system Multics, Unix, Unix-like, V, Plan 9, Inferno, SpartaDOS X, PANOS, Windows CE, KolibriOS
Platform Cross-platform
Type 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]

Contents

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 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.exeCommand Processor Shell includes the pwd command. [16]

pwd 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. [17] It appeared in Version 5 Unix. [18] The version of pwd bundled in GNU coreutils was written by Jim Meyering. [19]

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

*nix examples

CommandExplanation
pwdDisplay the current working directory. Example: /home/foobar
pwd -PDisplay 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 -LDisplay 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: [22]

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

See also

Related Research Articles

The Single UNIX Specification (SUS) is a standard for computer operating systems, compliance with which is required to qualify for using the "UNIX" trademark. The standard specifies programming interfaces for the C language, a command-line shell, and user commands. The core specifications of the SUS known as Base Specifications are developed and maintained by the Austin Group, which is a joint working group of IEEE, ISO JTC 1 SC22 and The Open Group. If an operating system is submitted to The Open Group for certification, and passes conformance tests, then it is deemed to be compliant with a UNIX standard such as UNIX 98 or UNIX 03.

<span class="mw-page-title-main">Unix shell</span> Command-line interpreter for Unix operating system

A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating system to control the execution of the system using shell scripts.

In computing, tar is a computer software utility for collecting many files into one archive file, often referred to as a tarball, for distribution or backup purposes. The name is derived from "tape archive", as it was originally developed to write data to sequential I/O devices with no file system of their own. The archive data sets created by tar contain various file system parameters, such as name, timestamps, ownership, file-access permissions, and directory organization. POSIX abandoned tar in favor of pax, yet tar sees continued widespread use.

ls Command to list files and directories in Unix and Unix-like operating systems

In computing, ls is a command to list computer files and directories in Unix and Unix-like operating systems. It is specified by POSIX and the Single UNIX Specification.

cd (command) Computer command in various operating systems

The cd command, also known as chdir, is a command-line shell command used to change the current working directory in various operating systems. It can be used in shell scripts and batch files.

mkdir Directory creation command on various operating systems

The mkdir command in the Unix, DOS, DR FlexOS, IBM OS/2, Microsoft Windows, and ReactOS operating systems is used to make a new directory. It is also available in the EFI shell and in the PHP scripting language. In DOS, OS/2, Windows and ReactOS, the command is often abbreviated to md.

uname Standard UNIX utility that prints name and other details about the machine

uname is a computer program in Unix and Unix-like computer operating systems that prints the name, version and other details about the current machine and the operating system running on it.

ln (Unix) Unix file management utility

The ln command is a standard Unix command utility used to create a hard link or a symbolic link (symlink) to an existing file or directory. The use of a hard link allows multiple filenames to be associated with the same file since a hard link points to the inode of a given file, the data of which is stored on disk. On the other hand, symbolic links are special files that refer to other files by name.

In computing, rmdir is a command which will remove an empty directory on various operating systems.

In computing, touch is a command used to update the access date and/or modification date of a computer file or directory. It is included in Unix and Unix-like operating systems, TSC's FLEX, Digital Research/Novell DR DOS, the AROS shell, the Microware OS-9 shell, and ReactOS. The command is also available for FreeDOS and Microsoft Windows.

In computing, echo is a command that outputs the strings that are passed to it as arguments. It is a command available in various operating system shells and typically used in shell scripts and batch files to output status text to the screen or a computer file, or as a source part of a pipeline.

cksum

cksum is a command in Unix and Unix-like operating systems that generates a checksum value for a file or stream of data. The cksum command reads each file given in its arguments, or standard input if no arguments are provided, and outputs the file's 32-bit cyclic redundancy check (CRC) checksum and byte count. The CRC output by cksum is different from the CRC-32 used in zip, PNG and zlib.

who (Unix)

The standard Unix command who displays a list of users who are currently logged into the computer.

rm (Unix) Unix command utility

rm is a basic command on Unix and Unix-like operating systems used to remove objects such as computer files, directories and symbolic links from file systems and also special files such as device nodes, pipes and sockets, similar to the del command in MS-DOS, OS/2, and Microsoft Windows. The command is also available in the EFI shell.

cpio is a general file archiver utility and its associated file format. It is primarily installed on Unix-like computer operating systems. The software utility was originally intended as a tape archiving program as part of the Programmer's Workbench (PWB/UNIX), and has been a component of virtually every Unix operating system released thereafter. Its name is derived from the phrase copy in and out, in close description of the program's use of standard input and standard output in its operation.

In computing, sleep is a command in Unix, Unix-like and other operating systems that suspends program execution for a specified time.

sum is a legacy utility available on some Unix and Unix-like operating systems. This utility outputs a 16-bit checksum of each argument file, as well as the number of blocks they take on disk. Two different checksum algorithms are in use. POSIX abandoned sum in favor of cksum.

help (command) Command in various command line shells

In computing, help is a command in various command line shells such as COMMAND.COM, cmd.exe, Bash, qshell, 4DOS/4NT, Windows PowerShell, Singularity shell, Python, MATLAB and GNU Octave. It provides online information about available commands and the shell environment.

In Unix and Unix-like operating systems, printf is a shell builtin that formats and prints data.

cat (Unix) Unix command utility

cat is a standard Unix utility that reads files sequentially, writing them to standard output. The name is derived from its function to (con)catenate files. It has been ported to a number of operating systems.

References

  1. "pwd(1) [minix man page]". www.unix.com.
  2. "pwd - print name of current/working directory - man page". www.mankier.com.
  3. "GNU Coreutils". www.gnu.org.
  4. Unix Time-Sharing System: Unix Programmer's Manual (PDF). Vol. 1 (7th ed.). Bell labs. January 1979. p. 142. Archived from the original (PDF) on 2005-05-20.
  5. "pwd(1) [plan9 man page]". www.unix.com.
  6. "pwd". pubs.opengroup.org.
  7. "pwd(1) [osf1 man page]". www.unix.com.
  8. "Apple OS X MAN page".
  9. "pwd(1) - OpenBSD manual pages". man.openbsd.org.
  10. "pwd(1) [opensolaris man page]". www.unix.com.
  11. "working_dir, wd, print_wdir, pwd (Multics help segment)". MIT. Retrieved 7 March 2020.
  12. Van Vleck, Tom. "Unix and Multics". Multicians.org. Retrieved 7 March 2020.
  13. "SpartaDOS X 4.48 User Guide" (PDF).
  14. "Chris's Acorns: Panos". chrisacorns.computinghistory.org.uk.
  15. "Shell - KolibriOS wiki". wiki.kolibrios.org.
  16. "Command Processor Commands (Windows CE 5.0)". docs.microsoft.com.
  17. wc   Shell and Utilities Reference, The Single UNIX Specification , Version 4 from The Open Group
  18. pwd(1)    FreeBSD General Commands Manual
  19. pwd(1)    Linux User Manual – User Commands
  20. "Identify current folder - MATLAB pwd". www.mathworks.com.
  21. "Function Reference: pwd". octave.sourceforge.io.
  22. "cd". pubs.opengroup.org.

Further reading