• 1-888-289-2246
  • 24x7x365 Presence

Argument list too long? Deleting the file or directory using its inode number


We’ve noticed that sometimes a file or directory has a really big size due to which removing it is not possible
and you get the message below:-

Argument list too long \*

This issue certainly happens with everyone and especially with the folder “Session”, where all the sessions of the server in a directory are kept. Recently I’ve faced this issue on an Linux server where the user stores the server’s sessions files at the location below:-

[root@server]# pwd
 /var/lib/sessions
[root@server lib]# cd /var/lib/
[root@server lib]# ls -al
drwxrwxrwx.  4 root  root  32875698 Nov 22 15:20 session

And I tried every possible way to remove the files inside it with the following commands:-

rm -rf session/*                                                    (remove all files inside the session directory)
find session/ -type f -name “*.sess” -exec rm {} ;      (removing files whose names end as .sess)
find session/* -mtime +50 -exec rm {} \;                 (removing files 50 days old)

But all give the same output as below after 1 hour:-

Argument list too long \*

At last, I tried the way which did remove the directory very quickly for me. I used the help of its inode number.

Step 1: Check the inode number of the directory using the command below:-

[root@server lib]# ls -li

1179686 drwxrwxrwx. 4 root  root  32875698 Nov 22 15:20 session

Above the first number, i.e. 1179686, is the inode of the directory session. Now remove the directory using the inode number with the command below:-

[root@server lib]# find . -inum 1179686 -exec rm -rf {} \;

“No such file or directory.”

And that’s it! The directory will be removed and after a few seconds you’ll get the message as above. That’s all!

]]>


Leave a Reply

Your email address will not be published. Required fields are marked *