Hi Friends! Today we will learn about the cd command which is used to play with directories and folders. Its full form has the secret what this command do c(change) d(directory).
So, let’s start with the cd command which is mainly used to change the directory in Linux, Windows as well as Unix.
Kindly refer the link so you can practice with us while learning the POST, it will take 40 to 50 seconds to boot the image.
$ cd tastethelinux output: [email protected]:~/tastethelinux$
so we have to change the directory successfully and moved into the folder tastethelinux
But are we in the right folder, so we will look for the new command known as “pwd”?
$ pwd output: /home/tla/tastethelinux
By using the pwd command we got that we are in /home/tla/tastethelinux folder.
pwd command stands for Present Working Directory, it always shows in which directory currently you are.
But what is /home/tla?
So, it is a home directory of the user tla lets see, how we can use with the cd command
So, from the above example, we can say that ~ this sign denotes the home directory of the user tla.
If we are anywhere in the directory we can use cd ~ to switch back to our home directory.
How to switch back to my working directory back tastethelinux use the command?
So, currently, we are in /home/tla/tastethelinux, and will go to the parent directory(means one step back)
[email protected]:~/tastethelinux$ cd ../ [email protected]:~$ pwd output: /home/tla [email protected]:~$
So, we have used “cd ../” command to go one step back.
What if we have to directly go to /home directory you can also use “cd ../../”
[email protected]:~/tastethelinux$ cd ../../ [email protected]:/home$
So, Guys that it for the cd command, if you want to learn mkdir command and ls command then visit this.
Let’s Play the Quiz Guys for the cd command, Are you ready to play with tastethelinux?
cd cheat sheet
1. Switch the directory Syntax: cd [directory_name] Example: cd tastethelinux
2. Go to home directory Syntax and Example: cd ~
3. Switch back to the working directory Syntax and Example: cd -
4. Switch back to previous directory Syntax and Example: cd ../
Thank you so much friends to read this post, Keep Supporting.
One Reply to “cd command in Linux with examples”