Ubuntu – How to display filetype with ls

command linels

I am ignorant as to whether ls is capable of displaying a filetype column.

Doing a quick online search and searching the man did not reveal such a capability. Is it capable of doing this?

Clarification: This is especially helpful if files do not have an extension.

Update

As of 2018-04-28 the answers have been quite interesting however they did not provide what I was looking for. More specifically,

  • file does give the actual filetypes but it doesn't integrate well with ls. Specifically, I use ls -lhtrpG --group-directories-first --color=always

  • ls -F is an ls solution however it provides symbols not a column of actual filetypes.

For this reason I have not marked any of the answers as the answer I am looking for.

Best Answer

I think the best way to display a file type is using this command:

file <filename>

If you want to list the types of all files in a directory, just use:

file *

<code>file *</code> sample from my computer

For more details about the arguments, see:

man file
Related Question