There are many ways to skin the cat. I just don't like the --forced option due to the lack of the root user. How backups are performed is kind of redirecting the argument here.
There are many ways to skin the cat. I just don't like the --forced option due to the lack of the root user. How backups are performed is kind of redirecting the argument here.
@TheFu
Agreed. No more hijacking.
I will use "su" mode instead of the "sudo" command prefix when attempting to delete many many root owned files in one command.
Why, because "sudo" has an arbitrary, and rather low, limit on the argument list.
Example: 10,000 root owned files:
Try to delete using "sudo":Code:doug@s15:~/sudo/test$ ls -l | head total 40000 -rw-r--r-- 1 root root 1024 Mar 22 09:07 ab00000000.txt -rw-r--r-- 1 root root 1024 Mar 22 09:07 ab00000001.txt -rw-r--r-- 1 root root 1024 Mar 22 09:07 ab00000002.txt -rw-r--r-- 1 root root 1024 Mar 22 09:07 ab00000003.txt ...
Now, delete using "su" to become root:Code:doug@s15:~/sudo/test$ sudo rm * sudo: unable to execute /bin/rm: Argument list too long
note that even root (and normal users, for their owned files) has an argument list limit, it's just way bigger.Code:doug@s15:~/sudo/test$ sudo su root@s15:/home/doug/sudo/test# rm * root@s15:/home/doug/sudo/test# exit exit doug@s15:~/sudo/test$
Example (100,000 files):
While not really relevant, my real life example is my tcpdump capture logs, at 10 minutes per file internal and external interfaces, which I tend to only post process every couple of months, thus I end up with thousands of files:Code:root@s15:/home/doug/sudo/test# rm * bash: /bin/rm: Argument list too long root@s15:/home/doug/sudo/test#
Code:-rw-r--r-- 1 root root 65534352 Mar 22 08:47 ext-2020-03-22-08-37-59.bin -rw-r--r-- 1 root root 516828264 Mar 22 08:57 ext-2020-03-22-08-47-59.bin -rw-r--r-- 1 root root 515930193 Mar 22 09:07 ext-2020-03-22-08-57-59.bin -rw-r--r-- 1 root root 536203868 Mar 22 09:17 ext-2020-03-22-09-07-59.bin -rw-r--r-- 1 root root 323516146 Mar 22 09:28 ext-2020-03-22-09-17-59.bin -rw-r--r-- 1 root root 81920 Mar 22 09:29 ext-2020-03-22-09-28-01.bin
Last edited by Doug S; March 22nd, 2020 at 05:31 PM.
Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.
xargs --max-lines=128000
or
xargs --max-chars=4096
will send chunks of arguments to the command.
https://www.gnu.org/software/finduti...mand-Size.html
Hello!
Thank you for reply may times!
I've read them.
Finishing checking, I will post about what I learn with a lot comments!
Hello malspa!
Do you use both of command?
I want to know subjective and objective,
both opinions.
Thank you for first comment!
I appreciate showing the most reliable page, yancek!
The part "Advantages and Disadvantages" seems suit
my question perfectly.
Thank you!
I understand that
Basically, it is better not to use su and sudo command with GUI programms.
And sudoedit is the best way to edit system files.
In other topic, how to allow users run su command in BSD,
some comment shows certain better way to changing
cunfiguration as well as you showed me.
I will break my system without such advice.
Thank you, TheFu!
I was just trying to reply to the question, but thanks. However, I am always wanting to learn more, but so far haven't been able to use xargs to overcome the issue. Note sure what I'm doing wrong.
EDIT: (I stopped being so lazy) This seems to work for 200,000 root owned files:
However, it can have issues also:Code:ls | xargs rm
which can be solved by, for example:Code:doug@s15:~/sudo/test$ ls *.txt | xargs rm -bash: /bin/ls: Argument list too long rm: missing operand Try 'rm --help' for more information. doug@s15:~/sudo/test$
however, if I try:Code:printf '%s ' *.txt | xargs rm
it doesn't work because the default list limit is too long, as per my original issue with sudo.But, and as the fu suggested, this works:Code:doug@s15:~/sudo/test$ printf '%s ' *.txt | xargs sudo rm sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long sudo: unable to execute /bin/rm: Argument list too long
Code:doug@s15:~/sudo/test$ printf '%s ' *.txt | xargs --max-procs=6 --max-args=1000 sudo rm doug@s15:~/sudo/test$ ls -l total 0
Last edited by Doug S; March 24th, 2020 at 08:15 PM.
Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.
Bookmarks