cd command stands for Change Directory. In this tutorial, we will learn some examples of the Change Directory command.
cd Linux Command
The cd command is used to traverse or navigate the directory tree from one directory to another in the Linux file system. The command is used to switch to another directory from the current present working directory. pwd command is used to know the present working directory.
$ cd /home/testingdocs/
$ cd eclipse
In the example, we have switched from /home/testingdocs/ to /home/testingdocs/eclipse directory using the cd eclipse command.
eclipse is an inner directory under the directory /home/testingdocs
We have used the cd command to know the contents of the eclipse directory and perhaps to launch the Eclipse IDE.
In this example, we have switched from /home/testingdocs to /home/testingdocs/Desktop directory. The pwd commands shows the current working directories of different times.
Use variable example
We can also use variables in the cd command. To change the current working directory, we can use the $HOME
$ cd $HOME
For example, we know that $JBOSS_HOME is set to the application server install directory. We want to switch to the bin directory under the server install directory. We can use the following command.
$ cd $JBOSS_HOME/bin
Notice that the current working directory has changed to /opt/wildfly/bin in the example.
Spot the Error
The below command displays an error in the Terminal. The following Error is displayed: No such file or directory.
Can you spot the error why bash complains it.
$ cd %JBOSS_HOME%/bin
Linux Basic Commands Tutorial page:
More Information on Ubuntu Linux: