chdir command

(Change directory)

Use the chdir command to change to another directory.

The syntax is chdir followed by the name of the directory you want to go to.
Example: chdir /home/user/www will change the directory you are in to /home/user/www.

> chdir /home/rich/www
> pwd
/home/rich/www
>

Line 1 shows the command chdir /home/rich/www, which should put me in the folder /home/rich/www
Line 2 is the pwd command (print working directory) to see if we are in the right directory
Line 3 is the output of the pwd command - which shows that we are indeed in /home/rich/www
Line 4 is the prompt again

Wildcards are also permitted.
Example: chdir /home/ri*/www would also take you to /home/rich/www, assuming there was no other folder in /home beginning with ri.

You can also use ../ to move you up one level in the file structure, or ../../ to move up two levels etc.
Example 1: If you are in /home/rich/www, then chdir ../ will take you to /home/rich, and ../../ will take you to /home.
Example 2: From /home/rich/www, chdir ../../bob will take you to /home/bob

This command is the same as the cd command.

Back to command index