cd (change directory) is a command used to switch directories/ folders from the terminal’s shell. You can press the tab button in order to auto complete the directory name.
Syntax
$ cd [directory]
Examples of CD command in Linux/Unix
ChangeĀ to home directory (determined by $HOME environment variable):
[adrian@mxforge]# cd
Change to home directory:
[adrian@mxforge]# cd ~
Show last working directory from where we moved from:
[adrian@mxforge]# cd --
Change to root directory:
[adrian@mxforge]# cd /
Change to parent directory:
[adrian@mxforge]# cd ..
Move three directories up from where you are now:
[adrian@mxforge]# cd ../ ../ ../
Change to subdirectory Documents and list all files:
[adrian@mxforge]# cd Documents && ls -la
Change to subdirectory Documents/Projects:
[adrian@mxforge]# cd Documents/Projects
If you wish to change to a directory with absolute path /home/user/Desktop:
[adrian@mxforge]# cd /home/user/Desktop
Change to directory name with white space – Where Are My Images:
[adrian@mxforge]# cd Where\ Are\ My\ Images
or
[adrian@mxforge]# cd "Where Are My Images"
or you can try
[adrian@mxforge]# cd 'Where Are My Images'
Change from current working directory to /usr/local/src without typing in full using TAB:
[adrian@mxforge]# cd /u<TAB>/l<TAB>/s<TAB>
Recent Comments