[TriLUG] How many character are allowed on the command line?

T. Bryan tbryan at python.net
Mon May 29 11:23:23 EDT 2006


On Monday 29 May 2006 09:55 am, Ralph Blach wrote:
> I am taking a class in computer science and the professor seems to
> indicate the the maximum number of character one can enter from the
> command line is 256 in both Windows command prompt  and the "IX's"
> command prompt.
>
>  From long ago, I seem to remember that this was  256 characters was a
> limitation of the DOS command prompt in Windows at one time,
> but never in  the "IX's" such as AIX, Linux, Solaris, .... .
>
> Could the knowledgeable Trilug community comment on this?

I don't think that it's been limited to 256 characters in any *nix I've used 
in the last 8+ years (Linux of various flavors, Solaris, Tru64).  

I'm running a Debian testing stock kernel.  After some experimentation, the 
command line limit seems to be right around 129910.  I'm sure that you could 
whip up a little program to use a binary search algorithm to find the maximum 
command line length on any unix system pretty quickly.

For Linux, I thought that it was actually a parameter that you could tweak 
when compiling your kernel.  

In any case, on a given system, I believe that it will be some fixed, finite 
size.  A limit of 256 would be annoying and could realistically get in the 
way of normal tasks.  :)  But any limit will eventually be exceeded by some 
systems person doing something odd with your program.  That's why xargs is 
popular.  :)

It's also why a lot of programs are written to take input from a STDIN in 
addition to the command line so that you can pipe commands together.  In a 
software development sense, you don't want to trap your users to always be 
putting the arguments on the command line.  Otherwise, they'll have to break 
up their input to run your program multiple times and different sets of 
arguments, and that might not always be equivalent.  Give them the option of 
specifying a file or piping data to your program via STDIN if possible.

---Tom



More information about the TriLUG mailing list