Pin Me

Linux Command Line: cd

written by: jlwallen•edited by: J. F. Amprimoz•updated: 7/4/2011

Working in the Linux command line interface wouldn't be possible without the "cd" command. Without "cd" you would find yourself locked into a directory. This entry to the Brighthub Linux Command Line series will outline this necessary tool for the Linux command line toolkit.

  • slide 1 of 3


    The "cd" command is one of those commands that would make your command line administration life quite challenging if you had to do without it. Why? The "cd" command allows you to change directories (hence the "cd") within the Linux directory hierarchy. The "cd" command comes from the old POSIX system call "chdir". As with many Linux commands "cd" is available for use in shell scripts and bash files.

  • slide 2 of 3


    As you would expect, the "cd" command is used to change from the current working directory to another directory. Since the "cd" command is a global command (the executable "cd" binary is in /usr/bin so all users have access to the command) you can use the "cd" command within any directory, no matter where you are in the filesystem hierarchy.

    In order to use the "cd" command you have to have a terminal window (such as gnome-terminal, konsole, or aterm) open. All commands will be entered at the bash prompt.

    Let's say, for example, you are in your home directory (in our example we'll use /home/jack) and you want to be in the /etc directory. To change to the /etc directory you would type the command cd /etc and hit enter to change to /etc. Now let's say you are in the /usr/share/e16/themes directory and you want to go back to your home directory. There are three ways you can do this: cd /home/jack, cd ~/, or cd. No matter which method you use, you will be in your home directory.

    Now let's say you are in /usr/share/e16/backgrounds and you want to move up a level to /usr/share/e16. Instead of typing cd /usr/share/e16 you could just enter cd ../ which moves you up one directory. If you wanted to move up two directories you would type cd ../../ and so on.

  • slide 3 of 3

    Final Thoughts

    You will find that in order to administer a Linux machine, the cd command will become an indispensable tool in your toolkit. Fortunately the cd command is a simple command to use. And don't worry about that "~" character. Eventually your fingers will get used to where it is and you'll be typing cd ~/ in your sleep.

© Copyright 2016