AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1253534
Accepted
skytwosea
skytwosea
Asked: 2020-06-25 18:01:10 +0800 CST2020-06-25 18:01:10 +0800 CST 2020-06-25 18:01:10 +0800 CST

如何确定 Linux 中的文件类型?

  • 772

我正在编辑 LS_COLORS 环境变量。dircolors列出不同文件类型的默认颜色。文件类型表示如下:

bd = (BLOCK, BLK)   Block device (buffered) special file
cd = (CHAR, CHR)    Character device (unbuffered) special file
di = (DIR)  Directory
do = (DOOR) [Door][1]
ex = (EXEC) Executable file (ie. has 'x' set in permissions)
fi = (FILE) Normal file
ln = (SYMLINK, LINK, LNK)   Symbolic link. If you set this to ‘target’ instead of a numerical value, the color is as for the file pointed to.
mi = (MISSING)  Non-existent file pointed to by a symbolic link (visible when you type ls -l)
no = (NORMAL, NORM) Normal (non-filename) text. Global default, although everything should be something
or = (ORPHAN)   Symbolic link pointing to an orphaned non-existent file
ow = (OTHER_WRITABLE)   Directory that is other-writable (o+w) and not sticky
pi = (FIFO, PIPE)   Named pipe (fifo file)
sg = (SETGID)   File that is setgid (g+s)
so = (SOCK) Socket file
st = (STICKY)   Directory with the sticky bit set (+t) and not other-writable
su = (SETUID)   File that is setuid (u+s)
tw = (STICKY_OTHER_WRITABLE)    Directory that is sticky and other-writable (+t,o+w)

如何确定文件或目录属于这些类别中的哪一个?

我为 LS_COLORS 引用的链接:

  • 配置 LS_COLORS
  • 颜色-Lscolors

使用file不起作用;查询目录告诉我该目录是……一个目录。但很明显,它有一个未显示的文件类型标志file,因为某些目录有一个绝对可怕的淡绿色突出显示白色文本。使用ls -lah也不起作用;权限字符串的第一个字母是d,这又是不够的信息。

Ubuntu 19.10 | KDE 等离子 5.16.5 | zsh 5.7.1

configuration kubuntu ls
  • 1 1 个回答
  • 891 Views

1 个回答

  • Voted
  1. Best Answer
    Eduardo Trápani
    2020-06-25T18:53:51+08:002020-06-25T18:53:51+08:00

    我不知道有一个程序会列出已知的文件类型dircolors。我怀疑没有,虽然这将是对 dircolors 的一个很好的补充但是你可以转储数据库并在那里找到你想要更改的那些。例如,对于目录:

    $ dircolors -p|grep dir
    
    # Configuration file for dircolors, a utility to help you set the
    # slackware version of dircolors) are recognized but ignored.
    DIR 01;34 # directory
    STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
    OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
    STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
    

    现在您知道有多少种不同类型的目录(对于dicolors,它们只是 的目录file。检查浅绿色目录上白色的权限ls -ld your_directory

    您还可以在系统中列出颜色及其含义。检查这个脚本。

    我知道这些步骤并不完全符合您的要求:获取 dircolors 用于某个节点的文件类型。但是,在两者之间,它们应该有助于调试,并且您可以为那些无法找到的文件类型调整颜色。

    • 5

相关问题

  • 如何为公共计算机配置 Ubuntu?

  • 如何设置默认启用网络?

  • 如何在键盘上映射未映射的键?[关闭]

  • 为什么我的 Kubuntu 会话在恢复后需要相当长的时间才能响应?

  • 保持多个工作站同步

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve