LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 11-05-2023, 06:13 PM   #1
compis
Member
 
Registered: Sep 2023
Posts: 35

Rep: Reputation: 0
Question Directory file size change


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

Last edited by compis; 11-05-2023 at 06:16 PM.
 
Old 11-05-2023, 07:58 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,360
Blog Entries: 28

Rep: Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148
It might help if you posted the output for the non-conforming item.

However, this thread from superuser might be of some use.
 
Old 11-07-2023, 07:09 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,679
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
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?")
 
Old 11-07-2023, 07:46 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,760

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
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.

https://askubuntu.com/questions/1073...inux-is-a-file
 
Old 11-08-2023, 12:57 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,245

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
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.
 
Old 11-08-2023, 10:10 PM   #6
compis
Member
 
Registered: Sep 2023
Posts: 35

Original Poster
Rep: Reputation: 0
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.
 
Old 11-09-2023, 03:21 PM   #7
arespi
LQ Newbie
 
Registered: Apr 2016
Posts: 13

Rep: Reputation: Disabled
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)
 
Old 11-09-2023, 08:13 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,364

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
As michaelk said
Quote:
As more files are added the directory file will increase but as also posted the size will not(!) decrease when files are deleted.
PS That's my exclamation mark there, just for emphasis.
It's actually quite a common qn for new users ...
 
Old 11-15-2023, 12:53 AM   #9
compis
Member
 
Registered: Sep 2023
Posts: 35

Original Poster
Rep: Reputation: 0
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?
 
Old 11-15-2023, 02:04 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336
just put some files into that dir and remove them.
 
Old 11-16-2023, 06:33 PM   #11
compis
Member
 
Registered: Sep 2023
Posts: 35

Original Poster
Rep: Reputation: 0
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.
 
Old 11-16-2023, 07:19 PM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,760

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
Code:
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
 
Old 11-17-2023, 01:11 AM   #13
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336Reputation: 7336
Quote:
Originally Posted by compis View Post
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 View Post
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)
 
Old 11-17-2023, 01:44 PM   #14
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,245

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
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 View Post
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.

Last edited by dugan; 11-17-2023 at 01:55 PM.
 
Old 11-19-2023, 03:37 AM   #15
compis
Member
 
Registered: Sep 2023
Posts: 35

Original Poster
Rep: Reputation: 0
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.
 
  


Reply



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
Linux Virtual Memory size; Page size; Resident Data Size; DB2Database; Explanation ANanalanalyzer Linux - Newbie 1 09-28-2018 04:50 PM
ls command to list out the file names,directory(along which file is present), file details(size,date time) at one go amala15vsa Linux - Newbie 1 10-09-2017 11:37 AM
Directory Size of etc, lost+found vs regular directory size. dumblinuxuser Linux - Newbie 1 06-07-2016 09:52 AM
[SOLVED] Store the size of largest file from a file/directory listing into variable SIZE lainey Linux - Newbie 3 11-15-2011 12:29 PM
Total partition size - User partition size is not equals to Free partition size navaneethanj Linux - General 5 06-14-2004 12:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 01:57 PM.

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
Open Source Consulting | Domain Registration