ls -al 출력의 필드는 무엇을 의미합니까? root root

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은 심볼릭 링크 (또는 소프트 링크)-특수한 유형의 파일
  • 소유자, 그룹 및 기타에 대한 권한을 나타내는 세 개의 문자 세트 (세 번) :
    • r = 읽을 수 있음
    • w = 쓰기 가능
    • x = 실행 파일

귀하의 예 -rwxrw-r--에서 이는 표시된 행이 다음을 의미합니다.

  • 일반 파일 (-로 표시됨)
  • 소유자에 의한 읽기, 쓰기 및 실행 가능 (rwx)
  • 그룹별로 읽기 가능하고 쓰기 가능하지만 실행 가능하지 않음 (rw-)
  • 다른 사람이 읽을 수는 있지만 쓰기가 불가능하거나 실행 가능

답변

“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

나열된 예제 파일의 링크 수가 너무 높은 이유를 잘 모르겠습니다. 어떤 플랫폼은 “링크”를 구성하는 것에 대한 이상한 개념을 가지고 있습니다. 여기에는 일반적으로 하드 링크 및 기호 링크와 디렉토리 항목이 포함됩니다 (디렉토리는 종종 링크 수가 많기 때문에 상위 디렉토리에는 하나의 링크가 있고 디렉토리에는 해당 .항목 에 대한 링크가 있으며 각 서브 디렉토리에는 을 통한 링크 ..).

일부 버전 및 / 또는 명령 행 플래그는 바이트 수 대신 사용 된 블록 수를 나열합니다. 블록 크기가 1024 바이트 인 파일 시스템은 최대 1024 바이트까지의 모든 크기를 “1”로 나열합니다. 즉, 1 개의 블록이 사용됨을 의미합니다. 1025에서 2048까지는 “2”로, 2 개의 블록을 사용하는 식입니다. 그러나 기본적으로 (명령 줄 옵션을 명시 적으로 사용하지 않고) 블록 크기를 나열하는 것은 대부분의 최신 un * x 시스템에서는 거의 없습니다.

특수 / 대체 액세스 플래그는 일반적으로 빈 공간이지만 일부 플랫폼에서는 특수 / 대체 액세스 모드 (예 : WIN32의 ACL 및 보안 설명자 등)가 있음을 나타내는 데 사용될 수 있으며 매우 다양합니다. 설명서를 참조하십시오. , 매뉴얼 페이지, 정보 도구 또는 기타 정보

권한 (모드) 플래그 (UUUGGGOOO)는 세 문자의 세 세트입니다. 첫 번째 세트는 “사용자”(예 : 소유자)이고 두 번째 세트는 “그룹”이고 세 번째 세트는 “기타”(예 : 다른 모든 사람)입니다. 소유자 또는 그룹이 아닌 사람). 각 세트의 세 가지 권한 플래그는 전형적으로 r또는 -파일 (읽을 수있는 사용자 / 그룹 / 기타 의미 r() 여부를 -다음), w또는 -그들이 파일에 쓸 수 있는지 여부를 나타내는 (당신은, 당신이 쓸 수있는 파일을 가질 수 있습니다 그러나 이상하게 들릴 수는 없습니다!), 세 번째 문자는 일반적으로 x실행 과 같은 다른 모드의 ‘캐치 올’플래그입니다 (디렉토리의 경우 디렉토리 내용에 액세스를 시도 할 수 있음). 또는 -아무도 없습니다.s또는 Ssetuid 및 / 또는 setgid 프로그램 또는 기타 덜 일반적인 문자; 표시 할 모드 문자에 대해서는 “ls”설명서를 참조하십시오.

마지막으로 첫 문자는 파일 형식입니다. 일반적으로 d디렉토리, l기호 링크 (하드 링크는 특수 문자없이 표시됨) 또는 -일반 파일 중 하나입니다. 다양한 파일 시스템에 대한 다른 파일 유형이 많지만 덜 일반적입니다. 이 첫 10 자 (파일 형식 및 권한)는 Wikipedia에서 설명 합니다 . 다시 말하지만, 문서는 명령이 지원하고 표시하는 파일 형식을 정확하게 알려줍니다.

BTW에서 “ls”자체 ( “man ls”/ “info ls”)에 대한 man / info 페이지를 찾을 수 없으면 “coreutils”패키지 ( “info coreutils”)를 찾아보십시오. 또한 일반적인 플랫폼 중에서 Microsoft 플랫폼은 “ls”출력으로 잘 변환되지 않는 경향이 있으므로 “ls”버전이 어떤지에 따라 출력에 이상한 동작, 플래그 또는 기타 비정상적인 정보가 표시 될 수 있습니다. 컴파일, 링크 된 내용 등

한 가지 더 경고 : 파일 타임 스탬프는 일반적으로 파일이 작성된 시간이 아니라 파일이 마지막으로 수정 된 날짜 / 시간 입니다. 사실, x * ish 파일 시스템에서는 파일 작성 시간에 대한 기록이 없습니다. ctime 필드는 FAT / NTFS 파일 시스템에서와 같이 “작성 시간”을 의미하는 것이 아니라 “inode [C] hange time”을 의미합니다. 즉 inode 자체가 마지막으로 수정 된 시간입니다. “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.


답변

첫 번째 열은 파일 모드이고 다음 열은 파일의 링크 수이며, 세 번째와 네 번째는 소유자 이름과 파일이 속한 그룹입니다. 다음 열은 파일의 바이트 수를 나타냅니다 (일부 ls구현에는 -h이 정보를보다 사용자 친화적 인 형식으로 볼 수있는 옵션이 있습니다). 마지막 두 열은 타임 스탬프와 파일 이름을 나타냅니다. 자세한 내용은 매뉴얼 페이지를 읽으십시오.


답변


이 글은 Unix 카테고리에 분류되었고 태그가 있으며 님에 의해 에 작성되었습니다.