Browse from one directory to another directory with change directory cd command.

 

Browse from one directory to another directory with change directory cd command.

 

Browsing from one directory to another directory with cd command. The example below show the basic step on using the cd command to navigates / browsing through directory on the Linux system.

 

Login to Linux using putty.

 

What happen after you login to Linux system? Where you want to go? and how you can go from one directory to another?... With the cd command we can go from one directory to another directory, the article below show the use step by step example using the cd command on fedora core system.

 

1.  Before you can change to another directory, it is better to execute the pwd command to make sure that you know your current working directory.

 

        login as: fedora

        fedora@10.7.0.168's password:

        [fedora@fedora ~]$ pwd

        /home/fedora

        [fedora@fedora ~]$

 

2.  Now we start using the cd command change to root (/) directory in your Linux system.

 

        [fedora@fedora ~]$ cd /

        [fedora@fedora /]$

 

        Verify with pwd command.

 

        [fedora@fedora /]$ pwd

        /

        [fedora@fedora /]$

 

        Using the ls command to list the root (/) directory contents.

 

        fedora@fedora /]$ ls

        bin etc lost+found mnt proc selinux tftpboot var

        boot home media net root srv tmp

        dev lib misc opt sbin sys usr

        [fedora@fedora /]$

 

3.  Now change from the current directory (/) to /etc directory.

 

        [fedora@fedora /]$ cd /etc

        [fedora@fedora etc]$

 

Verify your current directory.

 

        [fedora@fedora etc]$ pwd

        /etc

        [fedora@fedora etc]$

 

4. To get back to your home directory just execute cd command with no option or execute cd command with '~'.

Example1:

        [fedora@fedora etc]$ pwd

        /etc

        [fedora@fedora etc]$ cd

        [fedora@fedora ~]$ pwd

        /home/fedora

        [fedora@fedora ~]$

 

Example 2:

        [fedora@fedora etc]$ pwd

        /etc

        [fedora@fedora etc]$ cd ~

        [fedora@fedora ~]$ pwd

        /home/fedora

        [fedora@fedora ~]$

 

Note: The '~' singn is the substitute to user home directory.

 

Changing to single dot directory (.) and double dot dot directory (..).

 

When you execute ls -a, notice that there is special directory, dot and double dot directory.  These two (dot and dotdot) directory exist in every and each directory in Linux system.

 

        [fedora@fedora ~]$ pwd

        /home/fedora

        [fedora@fedora ~]$

        [fedora@fedora ~]$ ls -al

        total 112

        drwx------ 16 fedora fedora 4096 Apr 1 05:54 .

        drwxr-xr-x 13 root root 4096 May 5 17:44 ..

        -rw------- 1 fedora fedora 229 Jul 17 04:30 .bash_history

        -rw-r--r-- 1 fedora fedora 24 Mar 20 03:54 .bash_logout

        -rw-r--r-- 1 fedora fedora 176 Mar 20 03:54 .bash_profile

        -rw-r--r-- 1 fedora fedora 124 Mar 20 03:54 .bashrc

 

Note: The single dot represent the current directory, and double dot directory is the upper current directory. Now lets try little experiment to cd ing into these dot directory.

 

Cd to single dot directory.

 

        [fedora@fedora ~]$ pwd

        /home/fedora

        [fedora@fedora ~]$ cd .

        [fedora@fedora ~]$

 

Verify.

 

        [fedora@fedora ~]$ pwd

        /home/fedora

        [fedora@fedora ~]$

Note: from the command above, change directory into dot directory, not going to take you anyware.

 

CD to double dot directory:

 

        [fedora@fedora ~]$ pwd

        /home/fedora

        [fedora@fedora ~]$ cd ..

        [fedora@fedora home]$

 

Verify.

 

        [fedora@fedora home]$ pwd

        /home

        [fedora@fedora home]$

 

Note: from the command above, change directory into double dot directory, take you to upper current directory.

 

Summary:  The cd command is wery usefull to keep you going :-), but Linux have permission for each of the files and directory in the system, sometimes you cannot go to these directory because of you not have the right permission to access the directory.

Example of permission to access the directory is denied:

 

        [fedora@fedora home]$ cd /root

        -bash: cd: /root: Permission denied

        [fedora@fedora home]$

 

Command Information:

 

[root@fedora ~]# whatis cd

cd (1p) - change the working directory

cd [builtins] (1) - bash built-in commands, see bash(1)

[root@fedora ~]#

 

[root@fedora ~]# whatis ls

ls (1) - list directory contents

ls (1p) - list directory contents

[root@fedora ~]#

 

[root@fedora ~]# whatis pwd

pwd (1p) - return working directory name

pwd (1) - print name of current/working directory

pwd [builtins] (1) - bash built-in commands, see bash(1)

pwd.h [pwd] (0p) - password structure

[root@fedora ~]#

 

Keywords: cd, cd command, cd directory, linux cd command, change directory, change directory command, cding to directory, cd to folder, browse directory, browsing directory, go inside directory.

 

1 comment

27
Feb

bookmarking a directory for

bookmarking a directory for the cd command: http://www.youtube.com/watch?v=uWB2FIQlzZg

aaaaaaaaaaa