Change Directory (cd)
Change the current working directory.
Usage:
cd [DIRECTORY]
Examples
What Directory are we currently in?
pwd
/tmp/example
What directories are available in our current directory?
ls -l
total 8
drwxr-xr-x 2 kali kali 4096 Aug 25 16:43 dir1
drwxr-xr-x 2 kali kali 4096 Aug 25 16:43 dir2
-rw-r--r-- 1 kali kali 0 Aug 25 16:43 file1
-rw-r--r-- 1 kali kali 0 Aug 25 16:43 file2
Change to dir1 directory
cd dir1
Now we are in the dir1 directory
pwd
/tmp/example/dir1
ls -l
total 0
-rw-r--r-- 1 kali kali 0 Aug 25 19:44 file3
-rw-r--r-- 1 kali kali 0 Aug 25 19:44 file4
We can use two dots (..) in sequence to move back one directory level.
pwd
/tmp/example/dir1
cd ..
pwd
/tmp/example/
ls -l
total 8
drwxr-xr-x 3 kali kali 4096 Aug 25 19:45 dir1
drwxr-xr-x 2 kali kali 4096 Aug 25 17:50 dir2
-rw-r--r-- 1 kali kali 0 Aug 25 17:49 file1
-rw-r--r-- 1 kali kali 0 Aug 25 17:49 file2