深度阅读

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

作者
作者
2023年08月22日
更新时间
11.77 分钟
阅读时间
0
阅读量

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.

相关标签

博客作者

热爱技术,乐于分享,持续学习。专注于Web开发、系统架构设计和人工智能领域。