LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-06-2010, 06:25 AM   #1
pix9
Member
 
Registered: Jan 2010
Location: Mumbai, India
Distribution: Fedora 24 , Centos 7.0
Posts: 170

Rep: Reputation: 19
Question where does cd command comes from?


hello,
friends I have little weird doubt, well my doubt is that where does cd command came from, in linux, is it any binary like cat which is found in /bin direcotry, well I have tried searchig location for binary named cd but nothing came out. I have also tryed checking if it is alias to any other binary but was clueless.
can anyone please tell me when I execute cd command, which binary is executed?

thank you
regards

Last edited by pix9; 04-06-2010 at 06:26 AM.
 
Old 04-06-2010, 06:31 AM   #2
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 553

Rep: Reputation: 116Reputation: 116
Usually it will be a command however some shells may have it as a builtin. Try executing "which cd" and "whereis cd" for more info.
 
Old 04-06-2010, 06:44 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
I'd tell that usually it is a shell built-in. In any case, if we assume the existence of a cd binary executable, the command
Code:
$ type cd
should tell which one the shell actually uses.
 
Old 04-06-2010, 07:43 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by devnull10 View Post
Usually it will be a command however some shells may have it as a builtin. Try executing "which cd" and "whereis cd" for more info.
It cannot be an external command (well, it could but it would be useless).

Bash starts a new process to run external commands so any change of directory would no longer apply after running an external cd command. Here's simulating how an external cd command would not work.
Code:
c@CW8:~$ pwd
/home/c
c@CW8:~$ (
    cd /tmp
    pwd
)
/tmp
c@CW8:~$ pwd
/home/c
 
Old 04-16-2010, 03:26 AM   #5
pix9
Member
 
Registered: Jan 2010
Location: Mumbai, India
Distribution: Fedora 24 , Centos 7.0
Posts: 170

Original Poster
Rep: Reputation: 19
thank you for all your replies []
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to copy drive using dd and tee command parallely? source code of dd command mdfakkeer Linux - Software 1 02-10-2010 01:31 PM
[SOLVED] append command output to file by giving command in terminal sumeet inani Linux - Newbie 4 07-03-2009 10:36 AM
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 02:14 AM
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 06:30 PM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM


All times are GMT -5. The time now is 08:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration