Change Directory - change the current working Folder.
Syntax cd [-L|-P] [dir] Key -P Use the physical directory structure instead of following symbolic links (see also the -P option to the set builtin command) -L Force symbolic links to be followed
If a dir is given, changes the shell's working directory to name. If not, changes to HOME.
$ cd - will go back to the last folder you looked at. (Previous directory - equivalent to $OLDPWD)
The shell variable CDPATH provides a useful feature, this variable is similar to PATH but it sets up a list of paths where cd will search for subdirectories. CDPATH may be set on the command line for use in the current session, or in .bash_profile for permanent use, the list of paths must be colon separated (:)
If dir begins with a slash (/), then CDPATH is not used.
If a non-empty directory name from CDPATH is used, or if - is the first argument, and the directory change is successful, the absolute pathname of the new working directory is written to the standard output.
The return value is true if the directory was successfully changed; false otherwise.
Move to a subfolder named "Documents"
$ cd Documents
move to the fonts folder
$ cd /library/fonts
Change to another folder
$ cd ~/music
Move up to the parent directory (/Users/kate/)
To move up two levels:
$ cd ../..
Move to the top of the boot volume
$ cd /
Move to your home directory
$ cd ~
Move to a folder when the folder name includes spaces, parentheses or any other punctuation:
$ cd 'AppleWorks User Data'
“In times of change, learners inherit the earth, while the learned find themselves equipped to deal with a world that no longer exists” ~ Eric Hoffer
pwd - Print Working Directory
© Copyright SS64.com 1999-2013
Some rights reserved