cd
Files and directories
Usage
cd [path]Moves the shell to another directory; it is a shell builtin, so a cd inside a script or subshell never moves your outer shell.
Common flags
| Flag | Meaning |
|---|---|
| - | An argument rather than a flag: return to the previous directory |
| ~ | Your home directory; ~user is another user home |
| -P | Move to the real directory, resolving symlinks |
| -L | Keep the symlinked path (the default) |
Examples
cd -Jump back to where you just were.
cd ..Up one level.
cdWith no argument at all, go home.
Moving, deleting and finding. Some of these do not ask twice, which is why -i becomes a habit.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does cd do?
Moves the shell to another directory; it is a shell builtin, so a cd inside a script or subshell never moves your outer shell.
Q. How do I type it?
cd [path] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
4 are listed here; the full set is in man cd. This command sits under Files and directories.
Related commands
man page: man cd