Using the cd Command to Navigate the Terminal

Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Create a Linode account to try this guide with a $ credit.
This credit will be applied to any valid services used during your first  days.

What is cd?

On Linux systems, cd is a command that changes the directory you are in when working in the terminal. The cd command is one of the most used commands in Linux and has several shortcuts as well as two options.

Using the cd command

To change directories using cd:

cd [option] [directory]

For example, to navigate to the directory /usr/local, you would use the following syntax:

cd /usr/local

In the previous example an absolute path name was used. However you can also use a path relative to your current location. For example, if you are in /usr/local and want to change into /usr/local/share, you can do so with the following relative path:

cd share

Shortcuts in cd

Several shortcuts are available for cd which makes navigating between directories quicker and easier.

To navigate to the parent directory relative to where you are currently, use two consecutive dots (..):

cd ..

These dots can also be stacked to move up multiple levels:

cd ../../..

To change into the root directory, no matter your current location, use a forward slash /:

cd /

To change into your home directory, no matter your current location, use a tilde ~:

cd ~

You can also change into your home directory by using the cd command without any arguments:


To change to the last location, use a hyphen -:

cd -

This shortcut is helpful to toggle between two locations with long absolute paths to type. Note that it also returns the last location’s absolute pathname.

Options in cd

cd has two options, -L and -P.

The -L option forces symbolic links to be followed. This means if you tell the cd command to change into a directory that is a symbolic link, it will follow it and move you into the directory it’s pointing at instead of the directory specified. This is the standard behavior of cd and does not need to be specified. For example, if you want to change into /var/ but that’s a symbolic link to /var/www/ by issuing the following command, you will change into /var/www/

cd -L /var/

The -P option tells cd to use the physical directory structure and not to follow symbolic links. If you use this option, instead of navigating to where the symbolic link points to, you will change into the physical directory, if it exists. If the directory does not exist, the system will alert you with a directory does not exist error and you will remain in the current directory. For example, say you want to cd to a symbolic link /var/ that points to /var/www/, you will simply change into the directory and not follow the link:

cd -P /var/
If both -L and -P are specified, the -P option will be ignored.

This page was originally published on

Your Feedback Is Important

Let us know if this guide was helpful to you.

Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.
The Disqus commenting system for Linode Docs requires the acceptance of Functional Cookies, which allow us to analyze site usage so we can measure and improve performance. To view and create comments for this article, please update your Cookie Preferences on this website and refresh this web page. Please note: You must have JavaScript enabled in your browser.