cd command – How to Change a Directory in Linux?

Spread the love

cd command –

The cd stands for change directory. Just as you would click on a folder in Windows Explorer or Finder, cd switches you into the directory you specify. In other words, cd changes the working directory.

Let’s see where we are at this moment using the pwd command.

pwd

At this moment we are inside the workspace directory. And we can list the contents of this directory using ls command.

ls

Inside the workspace we have a lwd directory.

Let’s say you want to go inside the lwd directory. To do that we can write

cd lwd

And inside lwd directory, we have a README.md file and two directories data and notebooks.

Let’s go back to the the workspace directory which is one step above us. To move up one directory, we use cd ..

cd ..

Let’s say we want to go inside the lwd directory then inside the data directory in one go, without using two separate cd commands.

To do that we have to write

cd lwd/data

Let’s say we again want to go back to the workspace directory which is two step above us. To do that we will write.

cd ../..

Rating: 1 out of 5.

Leave a Reply