[opensuse] Re: /bin/chmod: Argument list too long - how long is too long?

David C. Rankin wrote:
Listmates,
I was trying to use chmod, but it says:
12:44 nirvana/srv/www/download> find . -type f -print0 | xargs -0 sudo chmod 0644 sudo: unable to execute /bin/chmod: Argument list too long
How long is too long? How many files will chmod do, or does it depend on the length of file names?
Your problem is sudo, not chmod. (And the other posters who recommeded to use xargs might want to read your post again.) sudo's notion of allowed argument list length differs from xargs. xarg's notion is probably right for Linux, and sudo's notion is safe for a wide variety of Unix systems. Try find . -type f -print0 | sudo xargs -0 chmod 0644 that should do the trick. This way sudo gets only 4 arguments, and not thousands. Semantically, it's the same. Joachim -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Joachim Schrod Email: jschrod@acm.org Roedermark, Germany -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org

Joachim Schrod wrote:
David C. Rankin wrote:
Listmates,
I was trying to use chmod, but it says:
12:44 nirvana/srv/www/download> find . -type f -print0 | xargs -0 sudo chmod 0644 sudo: unable to execute /bin/chmod: Argument list too long
How long is too long? How many files will chmod do, or does it depend on the length of file names?
Your problem is sudo, not chmod. (And the other posters who recommeded to use xargs might want to read your post again.) sudo's notion of allowed argument list length differs from xargs. xarg's notion is probably right for Linux, and sudo's notion is safe for a wide variety of Unix systems.
Try
find . -type f -print0 | sudo xargs -0 chmod 0644
that should do the trick. This way sudo gets only 4 arguments, and not thousands. Semantically, it's the same.
Joachim
Joachim, Thank you!!! That was it. One of these days I will learn, but I probably need to beat my head into the wall a time or two more. I tried and it worked without a problem. The script I was playing with was one that let me set the directory and file permissions recursively and the ownership for a directory tree with one short command instead of 2 long find commands and a chown. Things are always getting moved to my web directories that have unwanted permissions or ownership so this was a simple way to fix them. The scripts are more a learning exercise for me in input validation and default value handling as the find command alone could server the same purpose and a simple alias in .bashrc is much simpler. For the full setwebperm script see: http://www.3111skyline.com/download/linux/scripts/utils/setwebperms the same script, but without output or confirmation http://www.3111skyline.com/download/linux/scripts/utils/setwpq The only line you need to change if you want to use it is the OWNER line to set the user:group you want to set. I have yet put that in as $3. Thanks again for your help. -- David C. Rankin, J.D.,P.E. | openSoftware und SystemEntwicklung Rankin Law Firm, PLLC | Countdown for openSuSE 11.1 www.rankinlawfirm.com | http://counter.opensuse.org/11.1/small -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (2)
-
David C. Rankin
-
Joachim Schrod