How to display column headers for 'ls -l' command in unix/linux?

sunil_rbc picture sunil_rbc · Jan 28, 2016 · Viewed 31.9k times · Source

I want to display all the column headers when I type ls -l command in bash shell in unix/linux

When we type ls -ltr on command prompt we get something like the following.

-r--r--r--  2   makerpm   root   1898   Jan 28 14:52   sample3
-r--r--r--  2   makerpm   root   1898   Jan 28 14:52   sample1

What I want is to know whether ls has any options to display with column headers:

File_Permissions  Owner Group   Size   Modified_Time  Name
-r--r--r--  2  makerpm   root   1898   Jan 28 14:52   sample3
-r--r--r--  2  makerpm   root   1898   Jan 28 14:52   sample1

Answer

Bart Schuijt picture Bart Schuijt · Sep 28, 2017

exa is a replacement/enhancement for ls. If you pass on the arguments -lh with exa, it will include a header row printing the column names like so:

exa -lh

Example output:

Permissions Size User     Date Modified Name
.rwx------    19 username 29 Sep 11:25  dont_cra.sh
drw-r-----     - username 29 Sep 11:26  f1
.rw-r--r--@ 811k username 29 Sep 11:25  row_count.dat
.rw-r--r--    54 username 29 Sep 11:25  some_text.txt

You can set up an alias in .bashrc that replaces ls with exa.