该ls -al命令显示以下输出;
-rwxrw-r-- 10 root root 2048 Jan 13 07:11 afile.exe
Run Code Online (Sandbox Code Playgroud)
前面显示的所有字段是什么?
小智 301
按输出顺序;
-rwxrw-r-- 1 root root 2048 Jan 13 07:11 afile.exe
Run Code Online (Sandbox Code Playgroud)
-rwxrw-r--),1),root),root),2048),Jan 13 07:11),以及afile.exe)文件权限显示如下;
-,l或d。Ad表示目录,a-表示普通文件,l是符号链接(或软链接),其他字母用于其他类型的特殊文件+.在您的示例中-rwxrw-r--,这意味着显示的行是:
-)rwx)rw-) 执行r--)硬链接数是指名称的数量的一个inode,即与创建的链接ln 没有的-s选项。
C. *_* M. 119
“ls”命令的输出取决于“ls”的版本、使用的选项、使用的平台等。从您的示例中可以看出,您正在使用典型的 un*x(例如 Linux),并且可能使用典型的现代“ls”版本。在这种情况下:
-rwxrw-r-- 10 root root 2048 Jan 13 07:11 afile.exe
?UUUGGGOOOS 00 UUUUUU GGGGGG #### ^-- date stamp and file name are obvious ;-)
^ ^ ^ ^ ^ ^ ^ ^ ^
| | | | | | | | \--- File Size
| | | | | | | \-------- Group Name (for example, Users, Administrators, etc)
| | | | | | \--------------- Owner Acct
| | | | | \---------------------- Link count (what constitutes a "link" here varies)
| | | | \--------------------------- Alternative Access (blank means none defined, anything else varies)
| \--\--\----------------------------- Read, Write and Special access modes for [U]ser, [G]roup, and [O]thers (everyone else)
\------------------------------------- File type flag
Run Code Online (Sandbox Code Playgroud)
我不确定为什么您列出的示例文件的链接数如此之多。一些平台对什么是“链接”有一个奇怪的概念。这些通常包括硬链接和符号链接,以及目录条目(这就是目录通常具有高链接数的原因——它的父目录有一个链接,目录在.条目中有一个到它自己的链接,它的每个子目录都有通过..)返回的链接。
某些版本和/或命令行标志会列出使用的块数而不是字节数;块大小为 1024 字节的文件系统会将最大为 1024 字节的所有大小列为“1”,表示使用 1 个块,从 1025 到 2048 为“2”,使用 2 个块,依此类推。但是默认情况下列出块大小(没有明确使用命令行选项)在大多数现代 un*x 机器上很少见。
特殊/替代访问标志通常是一个空格,但在某些平台上,它可能用于表示存在特殊/替代访问模式(例如 WIN32 上的 ACL 和安全描述符等),并且差异很大 – 请参阅您的手册、手册页、信息工具等。
权限(模式)标志(UUUGGGOOO)是三组三个字符,其中第一组是“用户”(即所有者),第二组是“组”,第三组是“其他人”(即其他所有人) ; 既不是所有者也不是组的任何人)。每组中的三个权限标志通常是r或-表示用户/组/其他人可以读取文件 ( r) 或不可以 ( -),后跟w或-指示他们是否可以写入文件(您可以拥有可以写入的文件,但无法读取,听起来很奇怪!),并且第三个字符是其他模式的“全能”标志,通常类似于x执行(对于目录,这意味着您可以尝试访问目录内容),或者-没有。s或Ssetuid 和/或 setgid 程序,或其他不太常见的字符;有关它将显示的模式字符,请参阅您的“ls”文档。
最后,第一个字符是文件类型;通常是以下之一:d用于目录、l用于符号链接(硬链接通常显示时没有自己的特殊字符)或-用于普通文件。对于各种文件系统,还有许多其他但不太常见的文件类型。前十个字符(文件类型和权限)在 Wikipedia 上进行了讨论。同样,您的文档将准确地告诉您您的命令支持和显示的文件类型。
顺便说一句,如果您找不到“ls”本身的手册/信息页面(“man ls”/“info ls”),请尝试查看“coreutils”包(“info coreutils”)。另请注意,在更常见的平台中,Microsoft 平台往往无法很好地转换为“ls”输出,因此您可能会在输出中看到奇怪的行为、标志或其他异常信息,具体取决于您的“ls”版本编译,它与什么相关联,等等。
还有一个警告:文件时间戳通常是文件上次修改的日期/时间,而不是文件的创建时间。实际上,在 un*x-ish 文件系统上,没有文件创建时间的记录;ctime 字段并不像在 FAT/NTFS 文件系统上那样表示“创建时间”,而是表示“inode [C]hange 时间”——inode 本身上次修改的时间。"mtime" (last [M]odified) 和 atime (last [A]ccessed/read) 时间戳在两个系统上是相同的——尽管精度(例如 FAT 的粒度为两秒)和时区可能会有所不同.
rus*_*ush 34
在 GNU 系统上,它在ls信息页面中以非常详细的方式进行了描述。找到它所需要做的一切:只需打开man ls并在最后找到完整文档的链接:info coreutils 'ls invocation'.
这是它的引述:
`-l'
`--format=long'
`--format=verbose'
In addition to the name of each file, print the file type, file
mode bits, number of hard links, owner name, group name, size, and
timestamp (*note Formatting file timestamps::), normally the
modification time. Print question marks for information that
cannot be determined.
Normally the size is printed as a byte count without punctuation,
but this can be overridden (*note Block size::). For example, `-h'
prints an abbreviated, human-readable count, and
`--block-size="'1"' prints a byte count with the thousands
separator of the current locale.
For each directory that is listed, preface the files with a line
`total BLOCKS', where BLOCKS is the total disk allocation for all
files in that directory. The block size currently defaults to 1024
bytes, but this can be overridden (*note Block size::). The
BLOCKS computed counts each hard link separately; this is arguably
a deficiency.
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
The file mode bits listed are similar to symbolic mode
specifications (*note Symbolic Modes::). But `ls' combines
multiple bits into the third character of each set of permissions
as follows:
`s'
If the set-user-ID or set-group-ID bit and the corresponding
executable bit are both set.
`S'
If the set-user-ID or set-group-ID bit is set but the
corresponding executable bit is not set.
`t'
If the restricted deletion flag or sticky bit, and the
other-executable bit, are both set. The restricted deletion
flag is another name for the sticky bit. *Note Mode
Structure::.
`T'
If the restricted deletion flag or sticky bit is set but the
other-executable bit is not set.
`x'
If the executable bit is set and none of the above apply.
`-'
Otherwise.
Following the file mode bits is a single character that specifies
whether an alternate access method such as an access control list
applies to the file. When the character following the file mode
bits is a space, there is no alternate access method. When it is
a printing character, then there is such a method.
GNU `ls' uses a `.' character to indicate a file with an SELinux
security context, but no other alternate access method.
A file with any other combination of alternate access methods is
marked with a `+' character.
Run Code Online (Sandbox Code Playgroud)