How to display the file type using the ls command in Linux?

Published on Aug. 22, 2023, 12:17 p.m.

To display the file type using the ls command in Linux, you can use the -F (classify) option. This option will append a symbol to the end of each file name to indicate its type. Here are a few examples:

  • Regular file: no symbol
  • Directory: /
  • Symbolic link: @
  • FIFO (named pipe): |
  • Socket: =

Here is an example command that will display the file type and name for all files and directories in the current directory:

ls -F

This command will output a list of file and directory names in the current directory, with a symbol at the end of each file name indicating its file type.

Alternatively, you can use the -l (long format) option to display a list of files and directories along with their permissions, ownership, and file size, in addition to the file type symbol.

ls -l

This command will output a list of files and directories in the current directory, with the file type symbol appearing as the first character in the file permissions string.

Note that the -F option works well in combination with the -1 (one) option, which displays each file or directory on a separate line, making it easier to distinguish between them.

Tags:

ls