cd Command in Linux




In this blog we will learn how we can use cd command in Linux. cd command we can use to change the current working directory in Linux.
First of all lets open our terminal , We can press ctrl+alt+ t to do this .cd command can be given by just writing cd as it as on the eterminal and it can be used with the directory name also .

1.First of all whenever you give the cd command it is going to land you in the current home directory.

If we want to change directory to the root directory type forward slash after cd and then press Enter and now we are in the root directory . Command : $cd /

To check our current directory you can simply type $pwd . If you again want yo return to home directory you can simply type : $ cd ~

2.If we want to go to the parentdirectory of the current working directory you can simply type the command : $cd . .

3.You can also go to the any folder by just giving its absolute path . Comand : $ cd 'absolute path' .Say we want to go to document folder from our current directory , we can simply type the command : $ cd /home/username/Documents

4.To go to any of the directory you can just simply give the name of the directory .Command : $ cd 'directory name'

5.If you want to go to a folder which is two steps ahead of your current directory , means you want to go to a folder which is inside another folder , that means ; a->b->c , now you are in a you want to go to c , in that case command will be : $cd directory1/directory2/

6.Now we will see how you can go inside a folder which has space between its name . Example name of the folder: My folder .
There are three options you can use to navigate such kind of folder
a)First option is you can just write cd and then write My and then you give this backslash and then you give folder .Command : $cd My\ folder

b)The second option is instead of using backslash you can just write double quote and then you can just write My folder . Command : $cd "My folder"

c)The third option how you can go inside this folder of directory which has the space between it you can just give single quote around your directory names . Comamnd : $ cd 'My folder'

So here we covered details about cd command .


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





Be the first to comment

Leave a Reply

Your email address will not be published.


*