Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Hello everyone I'm getting started with Linux by learning some basic shell commands and noticed a strange omission:
The column labels for the output of ls -l command are missing.
(Note: that's a lowercase letter L and not an uppercase I or number 1. It may be deceiving depending on your system font)
I tried looking for the label names or column structure in the man pages but couldn't find anything about it.
So I looked it up online and found not only the answer, but there is also such thing as help and info commands as well. (Funny there is not a single standard for something like this). But I couldn't find the labels in those either.
Ultimately, there are a few different solutions online that seem a bit command specific or advanced for my skill level. But I hope to implement these solutions one day so I don't have to remember what the columns mean for commands like ls and others.
In the meantime, can someone point me to the spot in the man, info, and / or help pages which has the info I'm seeking?
There are times when I won't have the internet available for help, and I'm sure something so simple and fundamental such as column label has gotta be listed in there somewhere!
And if not, is there a "suggestion box" for things like this? I unfortunately don't know how to program or contribute yet.
The output from 'ls -l' is documented in "10.1.2 What information is listed" of 'info ls'.
The documentation tells you what type of info is listed, but not in order:
"In addition to the name of each file, print the file type, file mode bits, number of hard links, owner name, group name, size, and timestamp"
This is a just vague explanation that doesn't help someone with no internet who is just trying to figure out what "2" means, or "Total:16". Total what?? Why not label it?
The documentation for ls shows this when read at https://www.gnu.org/software/coreuti...is-listed.html
The very first line after the option name(s) gives the column headers, and those would greatly expand the width of the displayed values if the column widths matched the heading name.
Also, most of us can (and have been able to from the beginning) interpret what the columns means. Only the hard-link value may be misinterpreted. File mode bits == permissions, file type, etc
Code:
‘-l’
‘--format=long’
‘--format=verbose’
Produce long format. In addition to the name of each file, print the file type, file mode bits, number of hard links, owner name, group name, size, and timestamp (see Formatting file timestamps), normally the modification timestamp (the mtime, see File timestamps). If the owner or group name cannot be determined, print the owner or group ID instead, right-justified as a cue that it is a number rather than a textual name. Print question marks for other information that cannot be determined.
Normally the size is printed as a byte count without punctuation, but this can be overridden (see Block size). For example, --human-readable (-h) prints an abbreviated, human-readable count, and ‘--block-size="'1"’ prints a byte count with the thousands separator of the current locale.
For each directory that is listed, preface the files with a line ‘total blocks’, where blocks is the file system allocation for all files in that directory. The block size currently defaults to 1024 bytes, but this can be overridden (see Block size). The blocks computed counts each hard link separately; this is arguably a deficiency.
The file type is one of the following characters:
‘-’
regular file
‘b’
block special file
‘c’
character special file
‘C’
high performance (“contiguous data”) file
‘d’
directory
‘D’
door (Solaris)
‘l’
symbolic link
‘M’
off-line (“migrated”) file (Cray DMF)
‘n’
network special file (HP-UX)
‘p’
FIFO (named pipe)
‘P’
port (Solaris)
‘s’
socket
‘?’
some other file type
The file mode bits listed are similar to symbolic mode specifications (see Symbolic Modes). But ls combines multiple bits into the third character of each set of permissions as follows:
‘s’
If the set-user-ID or set-group-ID bit and the corresponding executable bit are both set.
‘S’
If the set-user-ID or set-group-ID bit is set but the corresponding executable bit is not set.
‘t’
If the restricted deletion flag or sticky bit, and the other-executable bit, are both set. The restricted deletion flag is another name for the sticky bit. See Structure of File Mode Bits.
‘T’
If the restricted deletion flag or sticky bit is set but the other-executable bit is not set.
‘x’
If the executable bit is set and none of the above apply.
‘-’
Otherwise.
Following the file mode bits is a single character that specifies whether an alternate access method such as an access control list applies to the file. When the character following the file mode bits is a space, there is no alternate access method. When it is a printing character, then there is such a method.
GNU ls uses a ‘.’ character to indicate a file with a security context, but no other alternate access method.
A file with any other combination of alternate access methods is marked with a ‘+’ character.
The link to this was at the very bottom of the man page for 'ls'
The documentation for ls shows this when read at https://www.gnu.org/software/coreuti...is-listed.html
The very first line after the option name(s) gives the column headers, and those would greatly expand the width of the displayed values if the column widths matched the heading name.
Also, most of us can (and have been able to from the beginning) interpret what the columns means. Only the hard-link value may be misinterpreted. File mode bits == permissions, file type, etc
Code:
‘-l’
‘--format=long’
‘--format=verbose’
Produce long format. In addition to the name of each file, print the file type, file mode bits, number of hard links, owner name, group name, size, and timestamp (see Formatting file timestamps), normally the modification timestamp (the mtime, see File timestamps). If the owner or group name cannot be determined, print the owner or group ID instead, right-justified as a cue that it is a number rather than a textual name. Print question marks for other information that cannot be determined.
Normally the size is printed as a byte count without punctuation, but this can be overridden (see Block size). For example, --human-readable (-h) prints an abbreviated, human-readable count, and ‘--block-size="'1"’ prints a byte count with the thousands separator of the current locale.
For each directory that is listed, preface the files with a line ‘total blocks’, where blocks is the file system allocation for all files in that directory. The block size currently defaults to 1024 bytes, but this can be overridden (see Block size). The blocks computed counts each hard link separately; this is arguably a deficiency.
The file type is one of the following characters:
‘-’
regular file
‘b’
block special file
‘c’
character special file
‘C’
high performance (“contiguous data”) file
‘d’
directory
‘D’
door (Solaris)
‘l’
symbolic link
‘M’
off-line (“migrated”) file (Cray DMF)
‘n’
network special file (HP-UX)
‘p’
FIFO (named pipe)
‘P’
port (Solaris)
‘s’
socket
‘?’
some other file type
The file mode bits listed are similar to symbolic mode specifications (see Symbolic Modes). But ls combines multiple bits into the third character of each set of permissions as follows:
‘s’
If the set-user-ID or set-group-ID bit and the corresponding executable bit are both set.
‘S’
If the set-user-ID or set-group-ID bit is set but the corresponding executable bit is not set.
‘t’
If the restricted deletion flag or sticky bit, and the other-executable bit, are both set. The restricted deletion flag is another name for the sticky bit. See Structure of File Mode Bits.
‘T’
If the restricted deletion flag or sticky bit is set but the other-executable bit is not set.
‘x’
If the executable bit is set and none of the above apply.
‘-’
Otherwise.
Following the file mode bits is a single character that specifies whether an alternate access method such as an access control list applies to the file. When the character following the file mode bits is a space, there is no alternate access method. When it is a printing character, then there is such a method.
GNU ls uses a ‘.’ character to indicate a file with a security context, but no other alternate access method.
A file with any other combination of alternate access methods is marked with a ‘+’ character.
The link to this was at the very bottom of the man page for 'ls'
The info in that web link appears to be a duplicate of what's already in the "info ls" command.
The closest you will get to column labels is this incomplete and out of order explanation:
"In addition to the name of each file, print the file type, file mode bits, number of hard links, owner name, group name, size, and timestamp"
I thought it also listed size in bytes? Frankly, this documentation seems incomplete and looks like a wall of text.
Regarding column widths, back in my spreadsheet days, we would alter text size or stack words for labels that were very long. That way the columns could fit to be a "normal", reasonable size.
But I guess if programs are relying on having no header in the output of ls - l (god forbid someone modifies their .profile or .bashrc to automatically include headers whenever the command is triggered), then there is no point in trying to get the columns added.
I guess It's just tribal knowledge that I will need to remember since the documentation does not really make things intuitive or foolproof. I get that for some people, they dont need to know if the number listed is a size in bytes, kilobytes, whatever. Its just implied cause, you know.... You know!
Even the checkbook I recently received from opening a new bank account is missing the labels for the Dollars, Date, Memo, and Payer lines. It only shows the "pay to the order of" label ...
I hadn't written a check in years so actually had to look this up on the internet since there was no "Documentation" on the check. Again, strange omission. But I suppose some are just born with better intuition and reasoning... I really do try to make sense of this world but its tough sometimes.
1. Unix was a freelanced skunkworks type project
2. on a very limited machine
3. they wanted to use the o/p automatically
4. written by system programmers for system programmers ...
I'm afraid you'll find that *nix cmds are all individuals, albeit there are some commonalities.
As a counter-example, df ALWAYS provides column headers, so you have to explicitly suppress them if you want to process the o/p automatically, eg
I guess It's just tribal knowledge that I will need to remember since the documentation does not really make things intuitive or foolproof.
That is an interesting question. ls (and most of the two-three letters commands) were developed at about 50 years ago. That time we had no enough resources to print everything. The headers (of ls) is unnecessary, and will be just annoying garbage - if you are already familiar with it - therefore it is omitted.
From the other hand you can implement your own tool which will do exactly what you want.
It was a bad decision to add a "total xxx" header for the ls -l
Why not a column header, augmented by a "(total xxx blocks)" at the end of the line?
Of course it must cater for the extra columns e.g. in
ls -lsi
The decision was made in the early Unix days, and no Unix or Linux distro ever dared to change it.
Yes, a change would break some existing (bad practice) scripts.
Last edited by MadeInGermany; 10-04-2023 at 03:02 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.