Changes the current directory.
cd [directory]
or
cd [directorya directoryb]
The cd command sets the current working directory of a process. The user must have execute (search) permission in the specified directory.
If a directory parameter is not specified, the cd command sets the current working directory to the login directory ($HOME in the ksh and bsh environments, or $home in the csh environment). If the specified directory name is a full path name, it becomes the current working directory. A full path name begins with a / (slash) indicating root directory, a . (dot) indicating current directory, or a .. (dot-dot) indicating parent directory. If the directory name is not a full path name, the cd command searches for it relative to one of the paths specified by the $CDPATH shell variable (or $cdpath csh variable). This variable has the same syntax as, and similar semantics to, the $PATH shell variable (or $path csh variable).
This command returns the following exit values:
0 | Successful completion. |
>0 | An error occurred. |
cd
cd /usr/include
This changes the current directory to /usr/include.
cd sys
If the current directory is /usr/include and it contains a subdirectory named sys, then /usr/include/sys becomes the current directory.
cd ..
The special file name, .. (dot-dot), refers to the directory immediately above the current directory.
/home/directorya/sub1/sub2/sub3/sub4the command
cd directorya directorybwill set the current working directory to
/home/directoryb/sub1/sub2/sub3/sub4if that directory exists. Additionally, if the current working directory is:
home/directorya/sub1/sub2/sub3/sub4the command
cd directorya directoryb/testwill set the current working directory to
home/directoryb/test/sub1/sub2/sub3/sub4if that directory exists. Likewise, if the current working directory is
/home/directoryb/test/sub1/sub2/sub3/sub4the command
cd directoryb/test directoryawill set the current working directory to
home/directorya/sub1/sub2/sub3/sub4if that directory exists.
Subdirectories must all have the same name.
The bsh command, csh command, ksh command, pwd command.
The chdir subroutine.
Directory Overview in AIX 5L Version 5.2 System User's Guide: Operating System and Devices describes the structure and characteristics of directories in the file system.
File Systems and Directories Overview in AIX 5L Version 5.2 System User's Guide: Operating System and Devices.
Shells Overview in AIX 5L Version 5.2 System User's Guide: Operating System and Devices describes shells, the different types, and how they affect the way commands are interpreted.