Spread the love

There are many commands in Linux and for this reason many people are worried about using the terminal. For this reason, today we will look at one of the main commands in Linux, the CD command. We will learn its most basic ways to use it and try to make your Linux experience more enjoyable.

What is the cd command? The cd (change directory) command was developed with the main purpose of changing the directory we are working in to move to another, if necessary. This cd command is a system integrated command, a.k. no external program or application is required, as it is executed directly by the Linux Shell. The cd command is available in all current Linux distributions.

00 – Basic syntax of the cd command

cd [-plvn][-| <Directory>].
Code language: CSS (css)

01 – How to change from the current directory to a new directory with the cd command in Linux

For this it is enough to start cd plus the new desired directory, for example:

cd /home/milen
cd command linux

02 – How to go back to the previous directory where we used to work with the cd command in Linux

This is practical because many times we have to go to a directory only for a specific query and then we have to go back to the original working directory. In this case, we need to do the following:

# go back to previous directory
cd -

# go back a folder up
cd ..
Code language: PHP (php)
cd command linux

03 – How to move to the home directory with the cd command in Linux

If we want to know what was the directory we were in before we had access to others, we will do the following:

To return directly to the Linux home directory, we have one of the following options:

# Go to home directory
cd ~


Code language: PHP (php)
cd command linux

04 – How to move two directories up from our current location with the cd command in Linux

If you are in a directory that contains multiple subdirectories and want to go to two levels, we will do the following.

cd ../..
cd command linux

05 – Navigate to a folder with a forgotten name

If for any reason you forgot the name of the folder you wanted to go but you remember the first letter here is a nice command

cd /home/m*
cd command linux

Quck video on the topic

We hope you enjoyed this article. if that is so please rate this page with the stars bellow and subscribe to our YouTube channel.

Leave a Reply