1

I have been using unix systems the majority of my life. I often find myself teaching others about them. I get a lot of questions like "what is the /etc folder for?" from students, and sometimes I have the same questions myself. I know that all of the information is available with a simple google search, but I was wondering if there are any tools or solutions that are able to add descriptions to folders (and/or files) that could easily be viewed from the command line? This could be basically an option to ls or a program that does something similar.

  • I would like there to be something like this:
    $ ls-alt --show-descriptions /
    ...
    /etc – Configuration Files
    /opt – Optional Software
    /bin - Binaries
    /sbin – System Binaries
    /tmp – Temporary Files
    ...
    
  • Could even take this a step further and have a verbose descriptions option:
    $ ls-alt --show-descriptions-verbose /
    ...
    /etc – The /etc directory contains the core configuration files of the system, use primarily by the administrator and services, such as the password file and networking files.
    /opt – Traditionally, the /opt directory is used for installing/storing the files of third-party applications that are not available from the distribution’s repository.
    /bin - The ‘/bin’ directly contains the executable files of many basic shell commands like ls, cp, cd etc. Mostly the programs are in binary format here and accessible by all the users in the Linux system.
    /sbin – This is similar to the /bin directory. The only difference is that is contains the binaries that can only be run by root or a sudo user. You can think of the ‘s’ in ‘sbin’ as super or sudo.
    /tmp – This directory holds temporary files. Many applications use this directory to store temporary files. /tmp directories are deleted when your system restarts.
    ...
    

I know that there is no default way to do this with ls, and to add such a feature would probably require a lot of re-writing of kernel code to account for the additional data being stored, so I'm not asking how to do this natively necessarily (unless there is an easy way I am overlooking). I am more asking if there is a tool that already exists for educational purposes that enables this sort of functionality? I guess it would take output from ls and then do a lookup to match directory names to descriptions it has already saved somewhere, but I digress.

3
  • 1
    This reminds me of 4DOS’s DESCRIPT.ION files. Something like that could be implemented in ls without kernel changes, e.g. using an extended attribute. Commented Sep 10, 2022 at 20:09
  • 1
    You can add descriptions for completions in zsh, but I'm not aware of anyone who has done so for well known directories Commented Sep 10, 2022 at 20:28
  • could attr help? Commented Jul 17, 2023 at 10:30

2 Answers 2

3

tree --info will do what you want.

You can create .info txt-Files that contain your remarks about

  • certain files and folders
  • or groups of files and folders (using wildcards).

tree --info will then show them in the directory listing.

Multi-line comments are possible.

There is also a Global info file in /usr/share/finfo/global_info that contains explanations for the Linux file system (see here). This file shows you also easily how the .info file syntax looks.

The homepage of the software is https://fossies.org/linux/misc/tree-2.1.1.tgz/.

2

The modern file systems, including ext* family has ability to create extended attributes to files. They could be managed by xattr tool

# set a comment
xattr -w user.comment "The cool file" file
# analogue to ls with comments
xattr -p user.comment *

The only limitation is that all additional attributes to a file (including the file name itself) should fit into FS's page. But nowadays it is not a real problem.

As far as I know, the ls does not read the extended attributes at all.

Also, if you are interested in a commander-style file managers: the Linux version of FAR Manager (far2l) works with the Descript.ion or files.bbs files. In both cases it is just a name description file formats.

There are rumors that the Midnight Commander is also able to work with the desript.ion files, but I am not sure how.

1
  • Strictly speaking ls (GNU ls on Linux at least) reads ACLs (though only reports their presence) and can read and report things like SELinux security contexts which are stored as extended attributes (system.posix_acl_access, security.selinux) Commented Sep 11, 2022 at 6:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .