Basics

Linux cd command

Move to another directory. Use “cd -” to return to the previous one.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

cd [-L | -P] [DIRECTORY]

Examples

Change to /var/log.

cd /var/log

Return to the previous working directory.

cd -

Parameters, options and clauses

Option / clauseDescription
-LFollow symbolic links and keep the logical path (default).
-PResolve symbolic links before changing directory.
-Change to the previous working directory.
--End option processing before the directory argument.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory