cd(1) cd(1)
NAME
cd - change working directory
SYNOPSIS
cd [directory]
DESCRIPTION
The shell built-in cd makes the specified directory your current work-
ing directory.
The cd command is rejected in a restricted shell [see sh(1)].
The Korn shell ksh has additional command-line options [see ksh(1)].
OPERANDS
directory
Name of the directory that is to become your current working
directory. You must have execute permission for this directory.
If you specify a relative or absolute path name for directory,
you must have execute permission for all the directories which
make up this path name.
If the name of the specified directory begins with one of the
following characters, the command looks for the directory without
reference to the CDPATH environment variable [see sh(1)]:
/ means that the search begins in the root directory.
./ means that the search begins in the current directory.
../ means that the search begins in the parent directory.
If the name of the specified directory does not begin with any of
the above characters, cd evaluates the CDPATH environment vari-
able:
- If the CDPATH variable has not been defined or is null, cd
looks for the specified directory relative to the current
working directory.
- If the CDPATH variable has been assigned a value, cd looks for
the specified directory sequentially in the directories whose
paths are defined in the CDPATH variable. On finding the
directory, cd writes the absolute path name of this directory
on standard output before switching to it.
directory not specified:
The cd command puts you in your home directory. The home direc-
tory is identical to the login directory unless there is a dif-
ferent path name assigned to the shell variable HOME.
Page 1 Reliant UNIX 5.44 Printed 11/98
cd(1) cd(1)
ERROR MESSAGES
file: does not exist
The specified directory does not exist. You can verify this with
ls -l.
file: not a directory
Your argument is not a directory. This can also be verified with
ls -l.
file: permission denied
You do not have execute permission for the specified directory.
If you have specified a relative or absolute path name for directory,
you do not have execute permission for one of the directories which
make up this path name.
cd: restricted
cd has been rejected because you are working in a restricted shell.
ENVIRONMENT VARIABLES
HOME
contains the absolute path name of your home directory.
CDPATH
You can assign to CDPATH the absolute path names of directories
that cd is to search.
By default this variable is undefined.
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed. If LCMESSAGES is undefined or is defined
as the null string, it defaults to the value of LANG. If LANG is like-
wise undefined or null, the system acts as if it were not internation-
alized.
EXAMPLES
Example 1
The following entry makes the subdirectory dates the current direc-
tory:
$ cd dates
$ pwd
/home/hofu/dates
Page 2 Reliant UNIX 5.44 Printed 11/98
cd(1) cd(1)
Example 2
User hofu has redefined the CDPATH environment variable. He now wishes
to change to his subdirectory usr, but with the following commands
ends up in the directory /usr instead:
$ echo $CDPATH
/:/home/hofu/dates:.
$ pwd
/home/hofu
$ ls -l
drwx--x--x 2 hofu 144 Feb 28 12:32 usr
drwx--x--x 2 hofu 192 Feb 28 11:51 dates
-rw------- 1 hofu 11734 Mar 7 16:22 tests
. . .
$ cd usr
$ pwd
/usr
The usr directory is first looked for in the directories whose path
names are assigned to the CDPATH variable. In this case, CDPATH con-
tains a / for the root directory as the first path name. The current
directory is the last to be searched by cd.
User hofu can prevent cd from evaluating the CDPATH environment vari-
able by formulating the command in the following way:
$ cd ./usr
$ pwd
/home/hofu/usr
NOTES
Some differences in behavior may occur when using cd, depending on
which shell is being used. The possible differences are not described
specifically.
SEE ALSO
ksh(1), pwd(1), sh(1), chdir(2).
Page 3 Reliant UNIX 5.44 Printed 11/98