> For the complete documentation index, see [llms.txt](https://snowyowls-organization.gitbook.io/snowyowl644-hacklog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://snowyowls-organization.gitbook.io/snowyowl644-hacklog/sekyuriti/linux-ji-chu.md).

# Linux 基礎

* /etc/passwd
  * ユーザー名、ユーザーID（UID）、グループID（GID）、ホームディレクトリ、ログインシェルなど、ユーザーアカウントに関する基本情報を格納
  * ユーザーのパスワード（ハッシュ値）も含んでいたが、セキュリティ上の理由から現在ではパスワードの欄が `x` などに置き換えられ、実際のパスワードハッシュは /etc/shadow に移されるのが一般的。
  * 多くのコマンドやサービスがユーザー情報を参照する必要があるため
  * 一般のユーザーでも読み取り可能（world-readable） どんな風に書かれているのか

|                |               |          |          |              |                      |                                   |
| -------------- | ------------- | -------- | -------- | ------------ | -------------------- | --------------------------------- |
| `htb-student:` | `x:`          | `1000:`  | `1000:`  | `,,,:`       | `/home/htb-student:` | `/bin/bash`                       |
| `<username>:`  | `<password>:` | `<uid>:` | `<gid>:` | `<comment>:` | `<home directory>:`  | `<cmd executed after logging in>` |

* /etc/shadow
  * パスワードのハッシュ値やパスワードの有効期限、パスワードの最終変更日など、主にパスワードに関わる詳細情報を格納している。
  * root のみが読み取れるように制限
  * パスワードハッシュが含まれる どんな風に書かれているのか

|               |                                   |                         |              |              |                     |                        |                      |                    |
| ------------- | --------------------------------- | ----------------------- | ------------ | ------------ | ------------------- | ---------------------- | -------------------- | ------------------ |
| htb-student:  | $y$j9T$3QSBB6CbHEu...SNIP...f8Ms: | 18955:                  | 0:           | 99999:       | 7:                  | :                      | :                    | :                  |
| `<username>`: | `<encrypted password>`:           | `<day of last change>`: | `<min age>`: | `<max age>`: | `<warning period>`: | `<inactivity period>`: | `<expiration date>`: | `<reserved field>` |
