Changing to another directory (cd command)
Use the cd command to move 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 the /(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).
- To change to your home directory, type the following:
cd
- To change to the /usr/include directory, type the
following:
cd /usr/include
- To go down one level of the directory tree to the sys directory,
type the following:
If the current directory is /usr/include and it contains a subdirectory named sys, then /usr/include/sys becomes the current directory.cd sys
- To go up one level of the directory tree, type the following:
The special file name, dot dot (cd ..
..
), refers to the directory immediately above the current directory, its parent directory.