change working directory
cd [ directory ]
cd changes the working directory to
directory. If you do not specify directory, the
new working directory will be set to the value of the environment
To change the working directory, the process must have search
(execute) permission in all directory components of the full
pathname of a directory to be changed to.
If the shell is reading its commands from a terminal, and the
specified directory does not exist (or some component cannot be
searched), spelling correction is applied to each component of
directory, in a search for the ``correct'' name. If a
reasonable match can be found, the shell asks whether or
not to try and change directory to the corrected directory name; an
answer of n means ``no,'' and anything else is taken as
Wildcard designators will work with the cd command.
cd is built in as part of the shell since the new working
directory must be set in the current shell.
recognize cd ~user to mean change to the home
directory of a specified user. The command cd ~
changes to the directory specified by the environment variable
ksh and sh implement the following cd
Note that ksh includes the following extensions to
If the specified directory does not exist and it does not
begin with ``/'', ``.'', or ``..'', cd
searches for a match to directory in the colon-separated
list of pathnames held by the environment variable
CDPATH. The working directory is set to the first match
The version of cd built into the Bourne, C, and
Korn shells supports the -L and -P flags for
following logical or physical paths. The default behavior for
ksh is to follow logical paths. The default behavior for
csh and sh is to follow physical paths.
If the current working directory is successfully changed, the
absolute pathname of the old working directory is saved in the
environment variable OLDPWD; PWD is set to the
absolute pathname of the new working directory.
The command cd - changes the working directory to the
value of OLDPWD. The pathname of the new working directory
is written to the standard output if successful.
Software storage objects (SSOs) preserve the traditional
directory structure and filenames by using symbolic links to point
to the real files which are maintained in the /var and
/opt/var directory hierarchies (see
Using the -L option to the version of cd built
into the Bourne and C shells allows you to traverse the
traditional directory structure while hiding the details of the
implementation of SSOs.
A typical setting of the environment variable CDPATH would
be (in ksh and sh only):
The command cd - in the ksh is equivalent to:
cd $OLDPWD && pwd
cd is conformant with:
ISO/IEC DIS 99452:1992, Information technology Portable Operating System Interface (POSIX) Part 2: Shell and Utilities (IEEE Std 1003.21992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005