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.

When I do - CD .. instead of cd ..
it gives me error saying -

CD: command not found

Why is the terminal case sensitive when it comes to linux commands? I mean you should be able to execute the command either with "all uppercase" or "all lowercase" characters.

I know it is due to some reason, but I am just curious.

share|improve this question
6  
I almost feel like this question should be re-titled Why are things case-sensitive? –  kojiro Jan 4 '13 at 17:02
11  
"I mean you should be able to execute the command either with "all uppercase" or "all lowercase" characters." Really? Why? –  dmckee Jan 4 '13 at 21:50
3  
Issue a stty iuclc olcuc if you feel like having a case insensitive terminal ;-) –  Stéphane Chazelas Jan 5 '13 at 17:07

5 Answers 5

up vote 25 down vote accepted

Ultimately, it was an arbitrary choice made by the creators of Unix over four decades ago now. They could have chosen to make things case-insensitive like the creators of MS-DOS did a decade later, but that has its disadvantages, too.

It's too deeply embedded in *ix culture to change now. The case sensitive filesystem issue brought up by eppesuig is only part of it. Mac OS X systems — which are Unix-based — typically have case-insensitive file systems, so on such systems commands external to the shell are in fact treated case-insensitively. But, builtins like cd remain case-sensitive.

Even with a case-insensitive filesystem, the history of things conspires against your wishes, Hussain. If I type ls on my Mac, I get a colorized directory listing. If I type LS instead, /bin/ls still runs, but the listing isn't colorized because the alias that adds the -C flag is case-sensitive.

Best just get used to it. If you can, learn to like it.

share|improve this answer
    
good. I get it. +1 –  Hussain Tamboli Jan 4 '13 at 11:53
1  
Actually Windows filenames can be case-sensitive. They are in the POSIX subsystem for example and see msdn.microsoft.com/en-us/library/ee681827%28v=vs.85%29.aspx –  fpmurphy1 Jan 4 '13 at 13:45
1  
It's actually surprising since some common terminals available at the time were in uppercase only and they had to implement a workaround (put a backslash before a letter if you want it to be really uppercase - enabled if you typed your username in all uppercase when you logged in) in the line discipline driver. –  Random832 Jan 4 '13 at 14:06

It's no more or less strange than the fact that we have an upper and lower case alphabet to start with. If you look in /usr/bin, you'll notice a (very) few executables exploit capitalization.

A case sensitive namespace is not just twice as big as an insensitive one -- the difference grows exponentially with word length. Eg, using 26 characters, there are 26^3 (17576) different possibilities in three letters; using 54 characters there are 54^3=157464). An open namespace is a good thing ;)

share|improve this answer
    
2*26!=56 in my opinion :) –  heinrich5991 Mar 29 '13 at 14:33

The technical systems that I use and respect are almost exclusively case-sensitive: be it OS or programming language or anything else.

The exceptions I could think of right now is the HTML tags and some implementations of SQL, and the Ada programming language.

Even in those cases, I think there are strong tendencies to actually write HTML tags in lowercase, and the SQL query semantics in uppercase (and parameters capitalized). (Correct me if I'm wrong.) As for Ada, the Emacs mode will correct you if you for example type a lowercase procedure name, although that won't matter when compiling. So, even when there is case-insensitiveness, it seems people agree it's a bad idea.

The reason is that you get much more expressive power with case-sensitiveness. Not only quantitatively - CD is one, but CD, Cd, cD, and cd are four - but more importantly, you can express purpose, emphasis, etc. using upper- and lowercase sensibly; also, when programming, you'll enhance readability.

Intuitively, it is clear that you don't read hi and HI the same way!

But, to give you a computer world example, in the programming language Ada (from the 1980s), the first line of a procedure code block could look like this:

procedure body P(SCB : in out Semaphore_Control_Block) is

as you see, the procedure and parameter names are capitalized, as are datatypes, everything else is lowercase. Also note that the "all uppercase" parameter name tells us that it is an acronym. Now, compare this to

procedure body p(scb : in out semaphore_control_block) is

This is possible, as Ada is case-insensitive (or, to be exact, the compiler will change it to the way in my first example, but of course won't change your code). Or, how about:

PROCedure body P(Scb : IN Out semaphore_CONTROL_BLOCK) iS

That one is a bit ridiculous, I know; but someone would be stupid enough to write it that way (well, perhaps not). Point is, a case sensitive system will not only force people to be consistent, they will also be helped by it (readability) and use it to their advantage (the acronym example above).

share|improve this answer
    
Thanks. took me some time to read and understand it, but very helpful +1. –  Hussain Tamboli Jan 4 '13 at 13:41
2  
Pascal and Delphi are also case insensitive. Also, having for example two variables length and Length is usually a bad idea:) –  Ajasja Jan 4 '13 at 16:27
    
@Ajasja: That's interesting, because Ada is a lot like Pascal. Well, I guess if you counted them all, there would be tons of such languages, because there are so many programming languages. As for length, of course - but you could possibly think of some such case: what about Max (a person), and max (a function that takes a list of reals, and returns the biggest)? –  Emanuel Berg Jan 4 '13 at 17:16
    
Regarding your last example, you might be interested to know that the QL's SuperBasic interpreter capitalised keywords in exactly that way: DEFine PROCedure Hello, for example. You only had to type the capitalised bits, but the full word appeared in program listings. This applied to REMark, too, and wasn't that annoying... –  David Given Apr 26 at 20:34

The concept of "upper/lower" case can be (and is indeed) a locale specific thing, which, as any other design complication should be pushed as close to the usage point as possible in the application stack, not be a part of the core.

Having case sensitive environment allows to wrap it into case insensitive environment, but not other way around.

share|improve this answer

This is not a "terminal" problem, it is a file system feature. How should the shell look for your commands on the (always case sensitive) file system?

share|improve this answer
    
And what if two or more commands match? –  scai Jan 4 '13 at 11:35
1  
The only option that may help you a little bit is a bash option called cdspell: it try to find the correct file name even if you tiped it wrong, but it is only working for command arguments. –  eppesuig Jan 4 '13 at 11:44
1  
@HussainTamboli There might be commands named cd, CD, cD and Cd each with a unique behavior. –  scai Jan 4 '13 at 12:04
3  
It's not really a file system feature or a terminal feature – it's a shell feature. Shell builtins will be case-sensitive on a case insensitive filesystem. Also, most shells hash commands, so commands are never really files, they're actually drawn from a hash. Try hash -p /bin/hostname HOSTNAME and now HOSTNAME is the command for /bin/hostname. –  kojiro Jan 4 '13 at 16:57
1  
Oh, I should also mention you can tell most shells to be less case-sensitive. For bash, you can bind set completion-ignore-case on. –  kojiro Jan 4 '13 at 17:06

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.