O'Reilly logo

Practical Linux by Bill Ball, John Ray, Michael Turner, M. Drew Streib

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Changing Directories with the cd Command

Use the cd (change directory) command to navigate through the Linux file system's directories. Use this command with a directory specification or pathname to move to a specified directory. This command is built in to each Linux shell, and can also be used as a shortcut to quickly move back to your home directory.

$ pwd
/home/michael
$ cd /usr/bin
$ pwd
/usr/bin
$ cd
/home/michael

If you enter the cd command by itself, you'll return to your home directory (specified in the $HOME environment variable). Move up to the next directory by entering two periods and a forward slash (../) with the cd command, like so:

$ pwd
/home/michael
$ cd ../
$ pwd
/home

SEE ALSO

To learn more about shell environment variables, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required