Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I was interviewed for an internship and I got the same question as this one: http://www.glassdoor.com/Interview/Which-2-letter-POSIX-command-is-different-from-all-the-others-QTN_498236.htm

The answer is right, it is cd (as the interviewer told me so). I am very confused at this one. Why cd is different? I told the interviewer that it is different because it might not be implemented by the "shell", but I did not know what I was talking about at that time.

share|improve this question
1  
I believe cd must be implemented by the shell. –  casey Dec 20 '13 at 0:43
    
@casey yeah I know, I must be very stupid when I answer this question. I just didn't know what to say at that moment. –  dorafmon Dec 20 '13 at 0:44
7  
Don't beat yourself up over this Q. It's a dumb Q, it needs to be qualified..."different how"? At any rate knowing this info as a new hire, matters why? This is another example of Unix elitists showing off and making themselves feel superior b/c they know some nonsense-less, useless bit of knowledge. –  slm Dec 20 '13 at 3:19
add comment

1 Answer

up vote 21 down vote accepted

This is of course a subjective question with many plausible answers.

A peculiarity of cd is that it has to be implemented by the shell itself: it cannot be an external command (one that runs in a separate program). cd changes the working directory of the shell process, and only the shell itself can do that.

This is a poor question because cd isn't the only such command. bg, fc, fg are in the same boat. cd existed before the others, which is one way to make it unique.

Another plausible answer would be dd, which has an option syntax that is entirely unlike any other command (it was borrowed from IBM).

Of course you can make arguments for many other commands, such as rm (the only 2-letter command that is purely destructive), su (the only two-letter command that absolutely has to be setuid root), at (the only two-letter command that is typically setgid), sh (it's the shell itself, which makes it different from the other commands which are special-purpose), ps (the two-letter command that varies the most between unices), etc.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.