Hi Alien Coders….its not an alien thing to write about cd. Yeah cd(change directory) not CD(Compact Disc) . Either you are working on Windows or Unix flavors O.S, the most easiest and usual command is cd, correct?
cd means change directory (as everyone knows) and its more powerful in Unix rather than Windows i guess. Window is having only cd path_of_the_diretory or cd .. but in Unix or specifically in Linux cd command is having lots of options. Lets explore one by one:
1. cd path_of_directory This command is used to enter into the directory whichever is specified either absolute or relative Ex: # cd /home/jaiswal/songs/audio/bollywood (absolute path) # cd songs/audio/bollywood (relative path when u r already at /home/jaiswal)
2. cd .. This command is used to move one step up form the current directory. If you are at /home/jaiswal/songs/audio/bollywood (keep it as a base of the examples) and want to move one directory up use cd .. Ex: # cd .. (now current directory will be /home/jaiswal/songs/audio) # cd ../../../movies (moved up three directories and entered into movies directory now i.e. /home/jaiswal/movies)
3. cd - This command comes very handy when you are working with files and one is at other directory and one is at another directory. For example: suppose one file is at /opt/bin/perl/codes and other is at /opt/bin/perl/modules/jaiswal/modules Now go to one directory using cd. Like cd /opt/bin/perl/codes then again type cd /opt/bin/perl/modules/jaiswal/modules and now use cd – You will be returned back to previous one which you used with cd. now use cd – as many time as you wish to switch over those two directories.
# cd /opt/bin/perl/codes Yes , you are right cd – is doing two work at a time.
# cd /opt/bin/perl/modules/jaiswal/modules
# cd - /opt/bin/perl/codes
# cd - /opt/bin/perl/modules/jaiswal/modules
1. Bringing back to previous used cd directory path and 2. also print the current directory path just like pwd
4. cd — or cd ~ or cd Yes all three commands will let you drive to user’s home directory most probably /home/user_name like /home/jaiswal ex: # cd — or cd ~ or cd (don’t write all three commands all together just i wrote. use any one if at one time buddy.) Windows have no such option as far as i have tried (if it is there let me know ) # pwd /home/jaiswal # I hope you will like it although even you know all these commands, you will find rarely any article on this which will explain like this. What say?
Latest posts by Sanjeev Jaiswal (see all)
- Optimizing Your Magento Store for better Usability - December 18, 2014
- How to know WordPress version of a site - November 24, 2014
- WordPress 4.0.1 got released with many security updates - November 21, 2014