LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 10-14-2011, 07:00 AM   #1
veeruk101
Member
 
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249

Rep: Reputation: 16
unable to execute /bin/chmod: Argument list too long


I'm trying to execute a chmod on every file (files only) in a directory, but get the following error. I thought I was getting this error before, but read something about using xargs was the solution. So I changed to using what you see below, and I'm actually quite surprised to be seeing this error again. Could you please advise how I can solve this?

find /path/to/dir -type f -print0 | xargs -0 sudo chmod 0664

sudo: unable to execute /bin/chmod: Argument list too long


I tried running the following command instead, but it was taking a really long time and I wasn't sure if it was doing the right thing so I killed it:

find /path/to/dir -type f -exec sudo chmod 0664 {} \;

Does it work the same as above, otherwise how are they different? And why doesn't the first command I tried work?
 
Old 10-14-2011, 07:11 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,

Try the following:
Code:
sudo find /path/to/dir -type f -exec chmod 0664 {} \;

# or

sudo find /path/to/dir -type f -print0 | xargs -0 chmod 0664
Hope this helps.
 
Old 10-14-2011, 07:16 AM   #3
veeruk101
Member
 
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249

Original Poster
Rep: Reputation: 16
Thanks for the guidance - turns out to work if you put the sudo not in front of chmod, and not in front of find either, but rather in front of xargs! So:

find /path/to/dir -type f -print0 | sudo xargs -0 chmod 0664

Now I know that it works, marking thread solved, but could anyone explain WHY it works that way?
 
  


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
-bash: /bin/: Argument list too long zeeshan673 Linux - General 4 02-22-2007 11:25 AM
bash: /bin/ls: Argument list too long. Workaround? Kropotkin Linux - General 3 02-28-2006 12:45 PM
bash: /bin/rm: Argument list too long? FiveFlat Linux - General 5 08-12-2004 12:29 AM
-bash: /bin/mv: Argument list too long balanagireddy Linux - General 2 07-28-2004 12:19 AM
/bin/rm: Argument list too long dragon49 Linux - Software 1 09-02-2003 01:27 PM


All times are GMT -5. The time now is 06:18 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