- Computer Networks
- Internet Related
- SAP Related
- Operating Systems
- Programming Languages
- Software Gossips
- Web World
- Mobile Technology
- Video Tutorials
- Guest Articles
- Contact Us
Everything about cd command in UNIX
Hi Alien Coders....its not an alien thing to write about cd. Yeah cd(change directory) not CD(Compact Disc) :P . 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.
Yes , you are right cd - is doing two work at a time.
# cd /opt/bin/perl/codes # 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?
Sun, 23/05/2010 - 08:02#1
Just want to say what a great
Just want to say what a great blog you got here! I've been around for quite a lot of time, but finally decided to show my appreciation of your work! Thumbs up, and keep it going! Cheers Christian.
Mon, 24/05/2010 - 19:08#2
Thanks a lot. Will keep our
Thanks a lot. Will keep our motivations and motto high to reach to the rest of the tech world
Tue, 01/06/2010 - 13:22#3
Just want to say what a great
Just want to say what a great blog you got here! I've been around for quite a lot of time, but finally decided to show my appreciation of your work! Thumbs up, and keep it going! Cheers Christian
Sun, 08/08/2010 - 16:51#4
thanx sir.... it will really
thanx sir.... it will really useful as nos lab going on
Thu, 27/09/2012 - 09:36#5
Hey, nice work... and the "cd -" move is sweet, didn't know about that one.