DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

cd(C)


cd -- change working directory

Syntax

cd [ directory ]

cd -

Description

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 variable HOME.

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 ``yes''.

Wildcard designators will work with the cd command.

Built-in versions

cd is built in as part of the shell since the new working directory must be set in the current shell.

Both ksh(C) and csh(C) 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 HOME.

ksh and sh implement the following cd functionality:

Note that ksh includes the following extensions to cd: 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.

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 hierarchy(M)). 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.

Examples

A typical setting of the environment variable CDPATH would be (in ksh and sh only):
   CDPATH=.:$HOME
The command cd - in the ksh is equivalent to:

cd $OLDPWD && pwd

See also

chdir(S-osr5), csh(C), ksh(C), pwd(C), sh(C)

Standards conformance

cd is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
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