LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 10-02-2023, 07:06 AM   #1
tuxman321
LQ Newbie
 
Registered: Oct 2023
Posts: 3

Rep: Reputation: 0
ls -l command output - missing labels


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.


Thanks!

Last edited by tuxman321; 10-02-2023 at 07:21 AM.
 
Old 10-02-2023, 07:29 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,710

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
Welcome to LinuxQuestions.

There are not any column headers displayed with the output of the ls -l command. Basically they are
Code:
permissions  number of hard links  owner name   group name   size in bytes   timestamp          file name
-rw-r--r--   2                      user         user         4096           Jul 25 13:54        test.dat
Seems the help information for their meaning is a bit scarce for current versions of the man page. I don't know why.

Last edited by michaelk; 10-02-2023 at 07:35 AM.
 
1 members found this post helpful.
Old 10-02-2023, 07:42 AM   #3
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,372

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
The output from 'ls -l' is documented in "10.1.2 What information is listed" of 'info ls'.
 
Old 10-02-2023, 07:59 AM   #4
tuxman321
LQ Newbie
 
Registered: Oct 2023
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by allend View Post
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?

Last edited by tuxman321; 10-02-2023 at 08:01 AM.
 
Old 10-02-2023, 08:10 AM   #5
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,372

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
Many scripts rely on the output of ls not to have labels. Yes, it is bad practice to parse ls output in scripts, but it is a persistent practice.

PS - Have you tried 'mc' as a command line tool?

Last edited by allend; 10-02-2023 at 08:24 AM.
 
1 members found this post helpful.
Old 10-02-2023, 06:48 PM   #6
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
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'
 
Old 10-02-2023, 08:57 PM   #7
tuxman321
LQ Newbie
 
Registered: Oct 2023
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by computersavvy View Post
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.

Last edited by tuxman321; 10-02-2023 at 09:10 PM.
 
Old 10-02-2023, 09:18 PM   #8
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,372

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
If you want headers, you could create an alias e.g.
Code:
alias lsl='echo -e "Permissions\tLinks\t Owner\tGroup\tSize\tDate\tName";ls -l'
 
1 members found this post helpful.
Old 10-03-2023, 12:48 AM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Basically this is down to :

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
Code:
df  | tail -n +2
Note that there is no 'no-headers' option

HTH

Last edited by chrism01; 10-03-2023 at 12:50 AM.
 
Old 10-03-2023, 01:28 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
Quote:
Originally Posted by tuxman321 View Post

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.
 
Old 10-04-2023, 02:51 AM   #11
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,796

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


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
Remove "dots" from labels in Cinnamon .window-list-item-labels LenHoff Linux - Software 2 10-30-2020 08:03 PM
ALSA - 2 Default Devices (Output + Input)? W/ Device Labels concorde Linux - Newbie 2 06-27-2020 03:16 AM
Disk labels are missing on pcmanfm-qt after glib2 update fulalas Linux - Software 1 06-21-2017 10:07 PM
LXer: Labels from the command line with LabelNation LXer Syndicated Linux News 0 08-27-2009 12:20 AM
1. how to set labels bottom margin? 2. how to set all labels to be right to left typi dfgfdgdf General 0 03-20-2007 09:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:21 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