命令"ls -l/dev/tty"的结果中的"c"是什么意思? [英] what's the meaning of 'c' in result of command "ls -l /dev/tty'?

查看:823
本文介绍了命令"ls -l/dev/tty"的结果中的"c"是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一些代码来解释Linux中ls命令的输出(以使其对新手更友好).作为测试用例之一,我执行了命令'ls -l/dev/tty',它返回了

I'm writing some code to interpret the output of the ls command in Linux (to make it more friendly to newcomers). As one of the test cases, I executed the command 'ls -l /dev/tty', and it returned

crw-rw-rw- 1 root root 5, 0 Apr 15 23:46 /dev/tty

第一列中的第一个字符'c'的含义是什么?我知道'd','l'和'-'.您可以列出该字段的所有可能值吗?

What is the meaning of first char 'c' meaning in first column? I know 'd', 'l', and '-'. Could you list all possible values for this field?

推荐答案

这是基于字符的(而不是基于块的)设备文件.

It's a character-based (as opposed to block-based) device file.

基于块的设备是有意义的(以足够多的方式)以块形式传输数据的任何设备.那样,我的意思是磁盘之类的东西.

Blocked-based devices are anything where it makes sense to transfer data in (surprisingly enough) blocks. By that, I mean things like disks.

基于字符的设备(再次,这应该不足为奇)倾向于一次传输字符.诸如终端,串行端口,打印机等之类的东西.

Character-based devices (and again, this should come as no surprise) tend to transfer characters at a time. Things like terminals, serial ports, printers and so on.

如果您正在运行一个不错的Linux发行版,则可以使用以下命令获取该信息(以及您可能需要的更多信息):

If you're running a decent Linux distro, that information (plus more than you could probably ever need) can be obtained with the command:

info ls

其中包含以下小片段:


The file type is one of the following characters:
    -  regular file
    b  block special file
    c  character special file
    C  high performance ("contiguous data") file
    d  directory
    D  door (Solaris 2.5 and up)
    l  symbolic link
    M  off-line ("migrated") file (Cray DMF)
    n  network special file (HP-UX)
    p  FIFO (named pipe)
    P  port (Solaris 10 and up)
    s  socket
    ?  some other file type

这篇关于命令"ls -l/dev/tty"的结果中的"c"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆