I am doing a university assignment at the moment which specifies that I list the command to; List all files, showing file types.

I have searched high and low to try and find the correct command to achieve this, but have had no luck!

Would somebody be able to help me out by pointing me in the right direction or maybe telling me what command could do this?

  • 2
    read about the ls command – Kamaraj Oct 13 '16 at 4:54
  • First, you need to define what you mean by "file type" - to a Windows user, that usually means a 'dot extension' on the filename, whereas in the *nix world it would more likely refer to the actual MIME type of the file (as determined by the file or mimetype commands). – steeldriver Oct 13 '16 at 10:38

"List all files, showing file types."

To see all files in the current directory and their file type, try:

file *


$ file *
apt.conf.d:                 directory
listchanges.conf:           ASCII text
preferences.d:              directory
sources.list:               ASCII text
sources.list.d:             directory
trusted.gpg:                GPG key public ring

The above shows a human-readable form of the file type. Alternatively, one can print the file's mime-type:

$ file --mime-type *
apt.conf.d:                 inode/directory
listchanges.conf:           text/plain
preferences.d:              inode/directory
sources.list:               text/plain
sources.list.d:             inode/directory
trusted.gpg:                application/x-gnupg-keyring

file does a cursory examination of the content of each file to determine its type. The default output, as shown in both examples above, includes the file name and the file type. For more information, see man file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.