[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Commands Reference, Volume 1

cd Command

Purpose

Changes the current directory.

Syntax

cd Directory ]

Description

The cd command moves you from your present directory to another directory. You must have execute (search) permission in the specified directory.

If you do not specify a Directory parameter, the cd command moves you to your 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 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).

NOTE: Running /usr/bin/cd from a shell does not change the shell's working directory.

Exit Status

This command returns the following exit values:

0 Successful completion.
>0 An error occurred.

Examples

  1. To change to your home directory, enter:
    cd
  2. To change to an arbitrary directory, enter:
    cd /usr/include
    This changes the current directory to /usr/include.
  3. To go down one level of the directory tree, enter:
    cd sys
    If the current directory is /usr/include and it contains a subdirectory named sys, then /usr/include/sys becomes the current directory.
  4. To go up one level of the directory tree, enter:
    cd ..
    The special file name, .. (dot-dot), refers to the directory immediately above the current directory.

Related Information

The bsh command, csh command, ksh command, pwd command.

The chdir subroutine.

Directory Overview in AIX Version 4.3 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 Version 4.3 System User's Guide: Operating System and Devices.

Shells Overview in AIX Version 4.3 System User's Guide: Operating System and Devices describes shells, the different types, and how they affect the way commands are interpreted.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]