This is a discussion on ls -l within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> I'm having trouble googling up a description of the fields produced by ls -l. For example: drwxr-xr-x 10 user ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I'm having trouble googling up a description of the fields produced by ls -l. For example: drwxr-xr-x 10 user users 20480 2007-02-15 12:13 filename I know what every one of these is except the second field. This is the output of a directory name using ls -ld, and I want to know why it's using 20k when every other dir uses 4k. I stumbled upon this as a possible problem producing a virtual host in apache, although I don't think it's really relevant to you fine folks. -- "Take that, you hostile sons-of-bitches!" -- James Coburn, in the finale of _The_President's_Analyst_ http://www.websterscafe.com |
| |||
| Handover Phist wrote: > I'm having trouble googling up a description of the fields produced by > ls -l. For example: > > drwxr-xr-x 10 user users 20480 2007-02-15 12:13 filename > > I know what every one of these is except the second field. This is the > output of a directory name using ls -ld, and I want to know why it's > using 20k when every other dir uses 4k. > > I stumbled upon this as a possible problem producing a virtual host in > apache, although I don't think it's really relevant to you fine folks. > this is the hard link count; it is the numbers of names that the file has (you can make hard link with ln). For directories, it gives the numbers of subdirectories of the directory + 1: 1 for the name of the directory 1 one for each .. presents in each subdirectories (this assume that you cannot make normal hard links to directories, as it is the case for ext2/3; it is possible that some filesystems authorize this). Olive |
| |||
| Handover Phist wrote: > I'm having trouble googling up a description of the fields produced by > ls -l. ... Google??? Did you try "man ls"? ls(1) on one of my systems has the following to say ... -l Write (in single-column format) the file mode, the number of links to the file, the owner name, the group name, the size of the file (in bytes), the timestamp, and the filename. > drwxr-xr-x 10 user users 20480 2007-02-15 12:13 filename > > I know what every one of these is except the second field. The number of links to the file: since this is a directory, it has one link at "/path/to/filename", and another at "/path/to/filename/." That's two links so far. Any subdirectory of that directory also has a link to it at "/path/to/filename/${subdir}/.." > This is the output of a directory name using ls -ld, and I want to > know why it's using 20k when every other dir uses 4k. The directory has (either currently, or at least at one time has had) a sufficient number of directory entries (files, subdirectories, symlinks, etc) to occupy more than one (as many as five, in this case) disk block. Understand that a "directory" is implemented simply as a "file" whose contents are directory entries that help the system locate other files on disk. If the directory has a sufficient number of directory entries, that "file" starts to need more than one disk block, then more than two, etc. When files within the directory are removed, the disk blocks are not freed, and the directory continues to occupy as much disk space as it did prior to the files within it being deleted. > I stumbled upon this as a possible problem producing a virtual host in > apache, ... I'd be surprised ... Details? -- ---------------------------------------------------------------------- Sylvain Robitaille syl@alcor.concordia.ca Systems and Network analyst Concordia University Instructional & Information Technology Montreal, Quebec, Canada ---------------------------------------------------------------------- |
| |||
| On Thu, 15 Feb 2007, Handover Phist wrote: > > drwxr-xr-x 10 user users 20480 2007-02-15 12:13 filename > > I know what every one of these is except the second field. This is the > output of a directory name using ls -ld, and I want to know why it's > using 20k when every other dir uses 4k. 2nd field is the hard link count. with, directory this is, basically, the number of sub-directories within that directory, plus one for '.' and one for '..' the size of the directory file grows, as filenames are added, from an initial 4k, to whatever size is needed to hold all those filenames. the details are fstype dependent. i'll bet your using ext2. if i'm wrong i'm sure someone will correct me :*) > I stumbled upon this as a possible problem producing a virtual host in > apache, although I don't think it's really relevant to you fine folks. it's a feature, not a problem :*) HTH -- William Hunt, Portland Oregon USA |
| |||
| On 2007-02-15, Sylvain Robitaille <syl@alcor.concordia.ca> wrote: > Handover Phist wrote: > >> I'm having trouble googling up a description of the fields produced by >> ls -l. ... > > Google??? Did you try "man ls"? > > ls(1) on one of my systems has the following to say ... > > -l Write (in single-column format) the file mode, the > number of links to the file, the owner name, the > group name, the size of the file (in bytes), the > timestamp, and the filename. Wow, must be because I'm using a Debian system at the moment. The entry for -l in my man page is: -l use a long listing format >> drwxr-xr-x 10 user users 20480 2007-02-15 12:13 filename >> >> I know what every one of these is except the second field. > > The number of links to the file: since this is a directory, it has > one link at "/path/to/filename", and another at "/path/to/filename/." > That's two links so far. Any subdirectory of that directory also has > a link to it at "/path/to/filename/${subdir}/.." > >> This is the output of a directory name using ls -ld, and I want to >> know why it's using 20k when every other dir uses 4k. > > The directory has (either currently, or at least at one time has had) a > sufficient number of directory entries (files, subdirectories, symlinks, > etc) to occupy more than one (as many as five, in this case) disk block. > > Understand that a "directory" is implemented simply as a "file" whose > contents are directory entries that help the system locate other files > on disk. If the directory has a sufficient number of directory entries, > that "file" starts to need more than one disk block, then more than two, > etc. When files within the directory are removed, the disk blocks are > not freed, and the directory continues to occupy as much disk space as > it did prior to the files within it being deleted. > >> I stumbled upon this as a possible problem producing a virtual host in >> apache, ... > > I'd be surprised ... Details? Sure. I have a server with as many as 20 virtual hosts on it. All hosts are running fine and dandy except for one, which is defaulting to the first named virtual server. the entries are as such: NameVirtualHost * <VirtualHost *> ServerName name.com ServerAlias name.com DocumentRoot /home/user/name </VirtualHost> Each entry is identical in implementation, but one of them just doesn't want to serve from it's own directory, and is listing itself as the first named server in the resulting error pages. The only difference I can see is a discrepancy in the dir size, which you've just explained. -- "Take that, you hostile sons-of-bitches!" -- James Coburn, in the finale of _The_President's_Analyst_ http://www.websterscafe.com |
| |||
| William Hunt wrote: > 2nd field is the hard link count. with, directory this is, > basically, the number of sub-directories within that directory, > plus one for '.' and one for '..' Not exactly: '..' is a link to the parent directory. You need a link *from* the parent directory which amounts for the second "required" link (one for '.', and one for '/path/to/dir') -- ---------------------------------------------------------------------- Sylvain Robitaille syl@alcor.concordia.ca Systems and Network analyst Concordia University Instructional & Information Technology Montreal, Quebec, Canada ---------------------------------------------------------------------- |
| |||
| On 2007-02-15, William Hunt <wjh@prv8.net> wrote: > On Thu, 15 Feb 2007, Handover Phist wrote: >> >> drwxr-xr-x 10 user users 20480 2007-02-15 12:13 filename >> >> I know what every one of these is except the second field. This is the >> output of a directory name using ls -ld, and I want to know why it's >> using 20k when every other dir uses 4k. > > 2nd field is the hard link count. with, directory this is, > basically, the number of sub-directories within that directory, > plus one for '.' and one for '..' > > the size of the directory file grows, as filenames are added, from > an initial 4k, to whatever size is needed to hold all those filenames. > > the details are fstype dependent. > i'll bet your using ext2. > if i'm wrong i'm sure someone will correct me :*) ext3, which basically makes you correct. Thanks! >> I stumbled upon this as a possible problem producing a virtual host in >> apache, although I don't think it's really relevant to you fine folks. > > it's a feature, not a problem :*) > > HTH It certainly is now that I know what that is. -- "Take that, you hostile sons-of-bitches!" -- James Coburn, in the finale of _The_President's_Analyst_ http://www.websterscafe.com |
| |||
| On Feb 15, 5:22 pm, Sylvain Robitaille <s...@alcor.concordia.ca> wrote: > William Hunt wrote: > > 2nd field is the hard link count. with, directory this is, > > basically, the number of sub-directories within that directory, > > plus one for '.' and one for '..' > > Not exactly: '..' is a link to the parent directory. You need a link > *from* the parent directory which amounts for the second "required" link > (one for '.', and one for '/path/to/dir') Exactly. And, it isn't the "number of sub-directories within that directory". Instead, the count includes each ".." link in each subdirectory. So, to recap... 1 parent hardlink, plus 1 /. hardlink, plus 1 subdirectory/.. hardlink for each subdirectory in the directory |
| |||
| On 2007-02-16, Lew Pitcher <lpitcher@sympatico.ca> wrote: > On Feb 15, 5:22 pm, Sylvain Robitaille <s...@alcor.concordia.ca> > wrote: >> William Hunt wrote: >> > 2nd field is the hard link count. with, directory this is, >> > basically, the number of sub-directories within that directory, >> > plus one for '.' and one for '..' >> >> Not exactly: '..' is a link to the parent directory. You need a link >> *from* the parent directory which amounts for the second "required" link >> (one for '.', and one for '/path/to/dir') > > Exactly. > > And, it isn't the "number of sub-directories within that directory". > Instead, the count includes each ".." link in each subdirectory. > > So, to recap... > > 1 parent hardlink, plus > 1 /. hardlink, plus > 1 subdirectory/.. hardlink for each subdirectory in the directory I can always count on you guys to give way more information than needed. Too bad all this puts the wife to sleep. -- "Take that, you hostile sons-of-bitches!" -- James Coburn, in the finale of _The_President's_Analyst_ http://www.websterscafe.com |
| ||||
| Handover Phist wrote: > .... snip ... > > Wow, must be because I'm using a Debian system at the moment. The > entry for -l in my man page is: > > -l use a long listing format If you continue reading you will find something like: The full manual is in info format, use "info ls" to access it. The problem on Ubuntu, and probably Debian, is that they fail to supply the .inf files. -- <http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt> <http://www.securityfocus.com/columnists/423> "A man who is right every time is not likely to do very much." -- Francis Crick, co-discover of DNA "There is nothing more amazing than stupidity in action." -- Thomas Matthews |