how to change directory in cmd change directory on linux

change directory command is one of the most important and widely used command for beginners as well as system administrator | cmd

how to change directory in cmd | change directory on linux | linux command cd | change directory in depth


change directory in cmd
linux command cd In-depth

Hello, guys welcome. In this Session, you will learn how you can use cd command in Linux.

 CD command we can use to change the current working directory in Linux. So let's see how we can use it so, first of all, I'm going to press ctrl + alt + T to open my terminal.  First of all, let's see the syntax of for "cd" so you can just use cd as it is and it can be used with the directory name.

$cd [directory Name]

linux command cd home

linux command cd home
linux command cd

$cd


So first of all whenever you give the cd command as it is going to land you in the current home directory. Whatever you open whenever you open the terminal for the first time it'll land you there.


change directory to root

linux command cd to root
linux command cd to root
$cd /
 

For example, we want to change directory to the root directory as we have seen in the first session, just say cd / and then press ENTER and now we are in the root directory / (slash) and by default, you have this tilde (~) which is a home. 


linux command cd ~

linux command cd ~
linux command cd ~
$cd ~


Now once again if you give cd and then this tilde (~) symbol then this means your home directory. The home directory is nothing but your home/username. So this tilde can be used also with cd command.


linux command cd go back

linux command cd back
linux command cd to back

$cd ..

Now there is a command of something like cd .. and it means we want to go to the parent directory of the current working directory.

So for example, our current working directory is home/usr which is my user directory. So when I give a cd .. then we will go one folder above or parent of the current folder. So I will just press ENTER and now you can see we are in the home folder.


linux command cd relative path

linux command cd directory
linux command cd directory

$cd directory Name


In my root directory, we have bin or usr or other folders. So to go inside those folders or to change the directory For example to the usr folder you can just write cd usr press ENTER and you will go to the usr folder.


linux command cd absolute path

$cd /usr/games


Once again I will go to my root folder and then you can also go to the usr folder by just giving its Absolute path. So you can just give cd /usr/games. So you can either give the Absolute path or you can give the relative path something like cd usr this is the relative path.

The relative path is nothing but whatever directory you see inside your present working directory you can just directly give the name of that directory.

cd command with spaces

Change directory command with space
linux command cd directory with space

Now next command is, For example, I want to navigate inside test folder and I will create one more folder, for example, I will say this is my file folder and if you observe I have left a space between my and file and I left the space intentionally. 

So when I do ls here it will show me there is a folder called my file but if you create a folder or directory with space then how you can navigate to this directory. For example, I will do my cd my file and press ENTER and will give me the error. 

Because cd is just looking for the first argument after the cd command and if it's a space there are two arguments. After the cd command how you can go inside the folder which has space between it. There are three options you can use to navigate such kind of folder.


method 1

linux command cd with space
linux command cd with spaces method 1

$cd my\ file

The first option is you can just write cd my\ file and when you press ENTER you will go inside this my file folder.

Method 2

linux command cd with space double quots
linux command cd with space method 2

$cd "directory Name"

The second option is instead of using this backslash (\) you can just write a double quote (") and then you can just write my file and press ENTER.

Method 3

linux command cd with space single quots
linux command cd with space method 3

$cd 'directoryName'

$cd 'directory Name'

The third option how you can go inside this folder or directory which has the space between you can just give a single quote (') around your directory names press enter and also you are in the same directory. 

Conclusion

So what are the command we have used today or we have learnt today,

  • cd command if you give then you will go to your home directory 
  • In order to navigate to a particular directory, I need to give its absolute path or relative path 
  • We have created a folder with a space between its name then you can use a cd and then either you can use backward slash (\) between the space or you can enclose this name between double quotes (") or single quotes (') and you will be inside that directory and you can work with it 
I hope you enjoyed this tutorial please rate comment and bye for now ❤💝

HAVE A GREAT DAY

See also,

Name

Apps,3,Games,1,Linux,38,Linux Commands,37,Terminal Apps,2,Termux,17,Userland,3,Windows,1,
ltr
item
Pro Tech guides: how to change directory in cmd change directory on linux
how to change directory in cmd change directory on linux
change directory command is one of the most important and widely used command for beginners as well as system administrator | cmd
https://1.bp.blogspot.com/-2pT09h37UHI/X7YWn8t6mTI/AAAAAAAACXA/Il8jrBsyU1sourknsP-glVeyonUJuhzXQCNcBGAsYHQ/s16000/linux%2Bcommand%2Bcd.png
https://1.bp.blogspot.com/-2pT09h37UHI/X7YWn8t6mTI/AAAAAAAACXA/Il8jrBsyU1sourknsP-glVeyonUJuhzXQCNcBGAsYHQ/s72-c/linux%2Bcommand%2Bcd.png
Pro Tech guides
http://www.protechguidez.com/2020/11/how-to-change-directory-in-cmd.html
http://www.protechguidez.com/
http://www.protechguidez.com/
http://www.protechguidez.com/2020/11/how-to-change-directory-in-cmd.html
true
7053638852026728047
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content