Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
When I perform a ls on most directories the file size is 4096 bytes but in a few cases I have seen the directory size change. an example is the app vocal it placed a cache file that was bigger than 4096.
What is occurring ? I can see no reason for the size of a directory to change and if there is a reason what is it
Normal listing
ls -l
total 40
drwxr-xr-x 6 name name 4096 Nov 4 09:14 Desktop
drwxr-xr-x 18 name name 4096 Nov 4 04:00 Documents
drwxr-xr-x 11 name name 4096 Nov 4 11:57 Downloads
drwxr-xr-x 3 name name 4096 Jun 23 03:14 Music
drwxr-xr-x 4 name name 4096 Oct 14 02:17 Pictures
drwxr-xr-x 2 name name 4096 Aug 12 18:11 Public
I guess you'd have to "dumpster dive" into the source-code of a particular filesystem to see exactly how it manages directories – which are, basically, "files containing lists of files." But I can easily imagine that, if a particular directory contained many files, its size would grow and it might or might not then decrease. (As in: "why bother?")
The basic generalization is that everything is a file even directories and as posted directories are files that are lists of other files. Given that in most filesystems the smallest something can be is one block which in most cases is 4096 now days. The directory file contains the filenames and basically their inodes. As more files are added the directory file will increase but as also posted the size will not decrease when files are deleted.
Yeah, a directory is a list of file names. If there are a lot of file names in that directory, then that would be an obvious reason for the different size.
This issue has nothing to do with files in the directory. I had this issue on mxlinux and a directory with a larger size than 4096 had only one small file, making think it is a security issue. I asked the Mxlinux forum to duplicate the issue with files in the directory and no one provided an example.
I stole this from another site, A directory is just a special file which contains an array of filenames and inode numbers. When the directory was created, the file system allocated 1 inode to the directory with a "filename" (dir name in fact). The inode points to a single data block (minimum overhead), which is 4096 bytes.
To see the size of the ocupied content of a directory use the command du (Disk utilization)
Arespi. The Inode has nothing to the direcotry size which is set. But If you think it is correct it should be possible to duplicate this situation, Can you offer a method to duplicate a change in a directory size?
I already stated this change of directory file size has noting to do with files in the directory. But if you think it does perfrom the task and state the directory name and the exact number of files you placed in it to change the directory size.
mkdir test
ls -ld test
... 4096 Nov 16 18:57 test
#!/bin/bash
for (( c=0; c<150; c++ ))
do
touch "~/test/fname-$c.txt"
done
ls -ld test
... 12288 Nov 16 19:01 test
rm ~/test/*
ls -ld test
... 12288 Nov 16 19:03 test
I already stated this change of directory file size has noting to do with files in the directory.
I'm sorry, I have to say it is wrong. The directory itself is "something" which contains files (and directories and other items). The more you put in, the bigger it gets. That is that simple.
Quote:
Originally Posted by compis
But if you think it does perfrom the task and state the directory name and the exact number of files you placed in it to change the directory size.
michaelk made it in the previous post (#12). If you don't understand: the code creates at about 150 empty files in a directory ~/test. Initially its size was "4096", at the end it was "12288". Finally, all the files were removed and the directory size did not change any further. You can still put in 50 files, 127, 151, 152 or even 10,000 files, remove [some] files and see how it works. (I think you need to do it yourself)
Look. If you're convinced that there's malware hiding in the directory (which is clearly what you've been insinuating for this entire thread), then just have the courage to say that.
What's clear to me is that you have no idea what a directory is. And that you've completely ignored the many very good explanations that have already been handed to you.
Quote:
Originally Posted by compis
I already stated this change of directory file size has noting to do with files in the directory.
The fact that you would "state" something this wrong, this late into the thread, is indisputable proof.
If those suggestions where valid dugan you would not have to post to say nothing.
Anyone who knows the answer would be able to give an example of how a directory file can change from 4096 to a larger value. So yes I believe this is hidden malware which no one noticed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.