Using cd command to change directory to another directory
Using cd command to change directory to another directory.
On Windows system we use to call folder, but on Linux system the folder is not a folder... they are call directory. The Linux system is base on directory hierarchy that start from root directory... so if you are from Windows worlds... there are no more folder :-) its only directory. To browse from one directory to another directory using Linux command line, Linux use cd command. The example below show how to use cd command to go from one directory to another directory on Linux system.
Before we start cd ing into Linux directory, you must understand the overview on how directory structured on Linux system. The simple way to show the list of directory hierarchy on Linux system is by using tree command... so... our cd command example below start with tree command
1. The command below show the directory tree on Fedora system. On this example we use tree command to show the directory hierarchy start from root directory. The ls commad also can show you the list of directory contents including list all directory.

[root@fedora ~]# tree -L 1 /
/
|-- bin
|-- boot
|-- dev
|-- etc
|-- home
|-- lib
|-- lost+found
|-- media
|-- mnt
|-- opt
|-- proc
|-- root
|-- sbin
|-- selinux
|-- srv
|-- sys
|-- tmp
|-- usr
`-- var
19 directories, 0 files
[root@fedora ~]#
2. To change directory or to go to /etc directory, use cd command and then path to the directory, in this case /etc directory. The example below show how to use cd command to go to etc directory.
[root@fedora ~]# cd /etc
[root@fedora etc]#
3. To verify that we are now in the etc directory (the directory that you want to go to), use pwd command as show on command example below.
[root@fedora etc]# pwd
/etc
[root@fedora etc]#
4. From there... you can use the cd command to go to other directory... just give the cd with path to directory that you want to go to. The cd command also can be use to go back to your home directory... just execute cd command without specifying any option.
[root@fedora etc]# cd
[root@fedora ~]#
5. Verify your directory location on Linux system by using pwd command again..
[root@fedora ~]# pwd
/root
[root@fedora ~]#
Cd command type and command location:
cd command location
[root@fedora ~]# type cd
cd is a shell builtin
[root@fedora ~]#
cd command type
[root@fedora ~]# type -t cd
builtin
[root@fedora ~]#
Cd command help manual:
cd command help and manual
[root@fedora ~]# help cd
cd: cd [-L|-P] [dir]
Change the current directory to DIR. The variable $HOME is the
default DIR. The variable CDPATH defines the search path for
the directory containing DIR. Alternative directory names in CDPATH
are separated by a colon (:). A null directory name is the same as
the current directory, i.e. `.'. If DIR begins with a slash (/),
then CDPATH is not used. If the directory is not found, and the
shell option `cdable_vars' is set, then try the word as a variable
name. If that variable has a value, then cd to the value of that
variable. The -P option says to use the physical directory structure
instead of following symbolic links; the -L option forces symbolic links
to be followed.
[root@fedora ~]#
Keywords: cd command, using cd command, change directory
- Add new comment
- 955 reads
- Tell your friends

Recent comments
17 weeks 36 min ago
21 weeks 2 days ago
21 weeks 2 days ago
24 weeks 6 days ago
24 weeks 6 days ago
30 weeks 15 hours ago
30 weeks 19 hours ago
30 weeks 1 day ago