【Linux】Linux argument list too long错误解决方法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了【Linux】Linux argument list too long错误解决方法相关的知识,希望对你有一定的参考价值。
参考技术A 在某个文件夹执行命令完全卡死,(ctrl+z,ctrl+c等都不能用),表现为:只好关闭当前shell,重新登录。
产生原因:
该文件夹中有一个服务挂载在该文件夹某一目录下,因突然关机等异常情况导致该服务无限制等待,机器重启后也不能正常连接。
解决方法:
查看与该文件夹相应的服务挂载情况:mount -l | grep 有问题文件夹名,如mount -l | grep "/root/bakup"
umount -l 文件夹,此刻,再访问文件夹即可使用命令了!
作为一个linux用户/系统管理员, 有些时候你会遇到以下错误提示:
bash: /bin/ls: Argument list too long
bash: /bin/rm: Argument list too long
产生原因:
“Argument list too long”参数列表过长错误经常发生在用户在一行简单命令中提供了过多的参数而导致,经常在ls *, cp *, rm * 等中出现,一般是因为受到 shell 参数个数限制所致
解决方法:
方法1 : 将文件群手动划分为比较小的组合
这是最基本的方法,只是简单的使参数数量符合要求,这种方法应用范围有限,只适用于文件列表中的名字分布比较均匀,另外这也是个初级用户可以考虑的解决方案,不过需要很多重复命令和对文件名分布的观察与猜测。
方法2 : 使用find命令
通过find命令,将文件清单输出到rm命令,使其一次处理一个,这样就完全避免了过量参数的存在,另外通过不同的参数,可以指定除了名称以外的时间戳,权限,以及inode等匹配模式。
方法3: 使用xargs命令
用xargs 命令将文件以每 100 个为一组为单位处理
xargs 命令会将文件以每 100 个为一组做 rm 处理。
方法4: 使用 ls 结合 awk 操作
可以使用 awk 一次删除一个的方式进行删除,但必须先进入该目录下。
Linux 命令 argument list too long 错误解决
https://blog.51cto.com/u_14782715/5082973
https://blog.csdn.net/fdipzone/article/details/41558461
Linux删除文件出现/bin/rm: Argument list too long解决方法
https://southcat.net/1481.html
Linux下经过 rm -f 删除大量文件时报错:Argument list too long
http://www.javashuo.com/article/p-pucmuhoh-v.html
Linux文件系统十问
https://mp.weixin.qq.com/s/pOKjwl3ONPMPSRF6RSmvaw
新建一个空文件占用多少磁盘空间?
https://mp.weixin.qq.com/s/9YeUEnRnegplftpKlW4ZCA
文件过多时ls命令为什么会卡住?
https://mp.weixin.qq.com/s/g-fFoYsBJkonV3ezdGDJKA
fdisk添加分区引起的Linux Error: 22: Invalid argument
[[email protected] ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[[email protected] ~]# fdisk -l
Disk /dev/sda: 584.6 GB, 584646328320 bytes
255 heads, 63 sectors/track, 71079 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 19441 156151808 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 19441 44937 204796672 83 Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3 44937 57685 102398336 83 Linux
Partition 3 does not end on cylinder boundary.
/dev/sda4 57685 71080 107595584 5 Extended
Partition 4 does not end on cylinder boundary.
/dev/sda5 57685 70433 102398336 83 Linux
/dev/sda6 70433 70949 4144768 82 Linux swap
/dev/sda7 70949 71080 1052288 83 Linux
Disk /dev/sdb: 146.1 GB, 146156158976 bytes
2 heads, 24 sectors/track, 5947109 cylinders
Units = cylinders of 48 * 512 = 24576 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 3 5947064 142729472 83 Linux
Disk /dev/sdc: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 13054 104856223+ 83 Linux
Disk /dev/sdd: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn‘t contain a valid partition table
[[email protected] ~]# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won‘t be recoverable.
The number of cylinders for this disk is set to 10443.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition‘s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
Disk /dev/sdd: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-10443, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-10443, default 10443):
Using default value 10443
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[[email protected] ~]# mkfs.ext3 /dev/sdd1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
10485760 inodes, 20970841 blocks
1048542 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=20971520
640 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[[email protected] ~]# more /etc/fstab
# This file is edited by fstab-sync - see ‘man fstab-sync‘ for details
LABEL=/1 / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=/u01 /u01 ext3 defaults 1 2
LABEL=/u02 /u02 ext3 defaults 1 2
LABEL=/u03 /u03 ext3 defaults 1 2
LABEL=SWAP-sda6 swap swap defaults 0 0
/dev/sdb1 /u03/flash_recovery_area ext3 defaults 1 2
/dev/sdc1 /u04 ext3 defaults 1 2
192.168.4.21:/volume1/NFSforLinux/7222 /mnt/nfsbak nfs defaults 0 0
/dev/hda /media/cdrecorder auto pamconsole,exec,noauto,managed 0 0
/dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0
[[email protected] ~]# vi /etc/fstab
# This file is edited by fstab-sync - see ‘man fstab-sync‘ for details
LABEL=/1 / ext3 defaults 1 1
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=/u01 /u01 ext3 defaults 1 2
LABEL=/u02 /u02 ext3 defaults 1 2
LABEL=/u03 /u03 ext3 defaults 1 2
LABEL=SWAP-sda6 swap swap defaults 0 0
/dev/sdb1 /u03/flash_recovery_area ext3 defaults 1 2
/dev/sdc1 /u04 ext3 defaults 1 2
/dev/sdd1 /u05 ext3 defaults 1 2
192.168.7.63:/volume1/NFSforLinux/7222 /mnt/nfsbak nfs defaults 0 0
/dev/hda /media/cdrecorder auto pamconsole,exec,noauto,managed 0 0
/dev/fd0 /media/floppy auto pamconsole,exec,noauto,managed 0 0
"/etc/fstab" 17L, 1285C written
[[email protected] ~]# mkdir /u05
[[email protected] ~]# mount -a
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 147G 90G 51G 65% /
/dev/sda7 1012M 34M 927M 4% /tmp
/dev/sda5 97G 78G 14G 86% /u01
/dev/sda3 97G 77G 15G 85% /u02
/dev/sda2 193G 165G 18G 91% /u03
/dev/sdb1 134G 95G 33G 75% /u03/flash_recovery_area
/dev/sdc1 99G 66G 28G 71% /u04
192.168.7.63:/volume1/NFSforLinux/7222
2.7T 1.9T 839G 70% /mnt/nfsbak
/dev/sdd1 79G 89M 75G 1% /u05
[[email protected] ~]# chown -R oracle:oinstall /u05
[[email protected] ~]# chmod -R 775 /u05
[[email protected] ~]#
以上是关于【Linux】Linux argument list too long错误解决方法的主要内容,如果未能解决你的问题,请参考以下文章
【Linux】Linux argument list too long错误解决方法
fdisk添加分区引起的Linux Error: 22: Invalid argument
Linux输出“Argument list too long”的解决方法
linux消息队列出错argument list too long