このls -alコマンドは、次の出力を表示します。
-rwxrw-r--    10    root   root 2048    Jan 13 07:11 afile.exe
上記の表示のすべてのフィールドは何ですか?
このls -alコマンドは、次の出力を表示します。
-rwxrw-r--    10    root   root 2048    Jan 13 07:11 afile.exe
上記の表示のすべてのフィールドは何ですか?
回答:
出力順に。
-rwxrw-r--    1    root   root 2048    Jan 13 07:11 afile.exe
ファイル許可は次のように表示されます。
-またはlまたはd、dはディレクトリ、行はファイル、lはシンボリックリンク(またはソフトリンク)-特殊なタイプのファイルあなたの例では-rwxrw-r--、これは表示される行が以下であることを意味します:
-以下のためではない非ディレクトリ、それがためだ通常のファイル、より多くありますr、wとxパーミッションを。ほとんどのシステムでは、最初のフィールドは、ACL、セキュリティ属性、その他の拡張属性などの追加属性の存在を示すためにも使用されます。また、シンボリックリンクの場合、シンボリックリンクのターゲットもの出力に表示されることに注意してくださいls -l。
                    number of links意味ですか?ありがとう。
                    info ls詳細があります
                    「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
リストしたサンプルファイルのリンクカウントがこれほど高い理由はわかりません。一部のプラットフォームには、「リンク」を構成するものについて奇妙な概念があります。これらには通常、ハードリンクとシンボリックリンク、およびディレクトリエントリが含まれます(これがディレクトリのリンク数が多い理由です。その親には1つのリンクがあり、ディレクトリには.エントリ内のそれ自体へのリンクがあり、そのサブディレクトリにはそれぞれ経由のリンク..)。
一部のバージョンおよび/またはコマンドラインフラグは、バイト数ではなく、使用されているブロック数をリストします。ブロックサイズが1024バイトのファイルシステムは、最大1024バイトまでのすべてのサイズを「1」としてリストします。つまり、1ブロックが使用され、1025〜2048が「2」として2ブロックが使用されます。しかし、ほとんどの最新のun * xマシンでは、デフォルトで(コマンドラインオプションを明示的に使用せずに)ブロックサイズをリストすることはまれです。
通常、特別/代替アクセスフラグは空白ですが、一部のプラットフォームでは、特別/代替アクセスモード(WIN32のACLやセキュリティ記述子など)があることを示すために使用される場合があります。 、マニュアルページ、情報ツール、またはその他。
許可(モード)フラグ(UUUGGGOOO)は3つの文字の3つのセットで、最初のセットは「ユーザー」(つまり所有者)、2番目のセットは「グループ」、3番目のセットは「その他」(つまり他の全員) ;所有者でもグループでもない人)。各セットの3つの許可フラグは、典型的rまたは-ユーザ/グループ/その他(ファイルを読むことができるという意味r)かない(-続く)wまたは-彼らはファイルに書き込むことができるかどうかを示す(あなたが書き込み可能ファイルを持つことができ、しかし、3番目の文字は他のモードの「キャッチオール」フラグであり、通常xは実行(ディレクトリの場合はディレクトリの内容にアクセスできることを意味します)のようなものです。また-はなし。sまたはS、setuidおよび/またはsetgidプログラム、またはその他の一般的でない文字の場合。表示されるモード文字については、「ls」ドキュメントを参照してください。
最後に、最初の文字はファイルの種類です。通常d、ディレクトリ、lシンボリックリンク(ハードリンクは通常、独自の特殊文字なしで表示されます)、または-通常のファイルのいずれかです。さまざまなファイルシステム用のファイルタイプは他にもたくさんありますが、あまり一般的ではありません。これらの最初の10文字(ファイルの種類と権限)は、Wikipediaで説明されています。繰り返しになりますが、ドキュメントには、コマンドがサポートおよび表示するファイルの種類が正確に記載されています。
ところで、 "ls"自体のman / infoページ( "man ls" / "info ls")が見つからない場合は、 "coreutils"パッケージ( "info coreutils")を調べてみてください。また、より一般的なプラットフォームの中で、Microsoftプラットフォームは「ls」出力にあまり変換されない傾向があるため、「ls」のバージョンに応じて、奇妙な動作、フラグ、またはその他の異常な情報が出力されることがありますコンパイル済み、リンク対象など
もう1つの注意点:ファイルのタイムスタンプは、通常、ファイルが作成された時刻ではなく、ファイルが最後に変更された日付/時刻です。実際、un * x-ishファイルシステムでは、ファイル作成時間の記録はありません。ctimeフィールドは、FAT / NTFSファイルシステムのように「作成時間」を意味するのではなく、「inode [C] hange時間」-iノード自体が最後に変更された時間を意味します。「mtime」(最後の[M] odified)およびatime(最後の[A] ccesed / read)タイムスタンプは両方のシステムで同じです。ただし、精度(FATの粒度は2秒など)とタイムゾーンは異なる場合があります。
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.
              /dev/
                    最初の列はファイルモード、次の列はファイルが持つリンクの番号、3番目と4番目はファイルの所有者とグループの名前です。次の列は、ファイルのバイト数を示しています(一部のls実装には、-hこの情報をよりユーザーフレンドリーな形式で表示するオプションがあります)。最後の2つの列は、ファイルのタイムスタンプと名前を示しています。詳細については、manページを参照してください。