When navigating through your server you may want to change to other directories. The cd command is the bash command to allow you to move to other folders within your account.
Command: cd
Synopsis: cd [dir]
Options:
Option | Long name | Description |
---|---|---|
-P | This forces the command to use the physical directory structure and does not include symlinks. | |
-L | This forces the command to use the logical directory structure and includes any symlinks. |
Examples
Below are a few examples of using the cd command. You can confirm your loction after running your cd command by using the pwd command.
cd [dir] – This command moves you to the path you specify. If you begin the path with a / it will start at the root folder for your account, as in the example below.
# cd /home/userna5/public_html # pwd /home/userna5/public_html
cd [dir] – Continuing the above example, not using a / in the path begins from your current location. In this example, we begin in the /home/userna5/public_html directory.
# cd images # pwd /home/userna5/public_html/images
cd .. – This command moves you to the directory just above your current location.
# pwd /home/userna5/public_html/images # cd .. # pwd /home/userna5/public_html
cd / – Using only the / as the path will return you to the root folder.
# cd / # pwd /
cd ~ – When using the ~ (tilde) character as the path, you will be returned to your home directory. The example below assumes a user named userna5.
# cd ~ # pwd /home/userna5