LoginSignup
0
0

1.マニュアルファイル

Linuxでは、インストールされているコマンドやsshd_configなどのconfigファイルについてのマニュアルが.gz形式で用意されており、これをmanコマンドで表示する事ができます。

2.使い方

使い方は至って簡単で、

man command

で見る事ができます。試しにchmodコマンドのマニュアルを見てみましょう。

実行例

man chmod
CHMOD(1)                                           User Commands                                          CHMOD(1)

NAME
       chmod - change file mode bits

SYNOPSIS
       chmod [OPTION]... MODE[,MODE]... FILE...
       chmod [OPTION]... OCTAL-MODE FILE...
       chmod [OPTION]... --reference=RFILE FILE...

DESCRIPTION
       This  manual  page documents the GNU version of chmod.  chmod changes the file mode bits of each given file
       according to mode, which can be either a symbolic representation of changes to make,  or  an  octal  number
       representing the bit pattern for the new mode bits.

       The  format of a symbolic mode is [ugoa...][[-+=][perms...]...], where perms is either zero or more letters
       from the set rwxXst, or a single letter from the set ugo.  Multiple symbolic modes can be given,  separated
       by commas.

       A  combination  of  the letters ugoa controls which users' access to the file will be changed: the user who
       owns it (u), other users in the file's group (g), other users not in the file's group  (o),  or  all  users
       (a).   If  none  of these are given, the effect is as if (a) were given, but bits that are set in the umask
       are not affected.
...

 Manual page man(1) line 1 (press h for help or q to quit)

3.マニュアルページの操作(簡易版)

マニュアルページは次のように表示を操作できます。

上下スクロール

上下のキーまたはkjキーでスクロールします。

ページ移動

PageUpPageDownまたはbSpaceキー、Ctrl + B,Ctrl + Fキーでページ単位で移動できます。

検索

/を押した後にキーワードを入力して検索できます。

終了

qキーでマニュアルページの表示を終了します。

ヘルプ

hキーでマニュアル表示のヘルプを表示できます。その他の細かい操作法はこちらで確認する事ができます。

4.マニュアルページの構成

マニュアルページは基本的に以下のようなセクションで構成されています。ただ、これらの項目は一部なかったり、これ以外の項目があったりします。

1.NAME

  • コマンドの名前と簡単な説明

2.SYNOPSIS

  • コマンドの使用方法や構文

3.DESCRIPTION

  • コマンドの詳細な説明

4.OPTIONS

  • コマンドで使用可能なオプションの説明

5.EXAMPLES

  • コマンドの使用例

6.SEE ALSO

  • 関連コマンドやマニュアルのページ

5.マニュアルページのセクション

マニュアルページを開くとMAN(1)などのように、括弧書きで数字が表示されています。
これはセクション番号を意味しています。
この、マニュアルのセクション番号には一般的に次のような意味があります。

1.実行可能プログラムまたはシェルコマンド

  • 例:ls, cd, grep
  • 通常のユーザーが使用するコマンドやプログラムのマニュアルです。

2.システムコール(カーネルによって提供される関数)

  • 例:read, write, open
  • カーネルが提供する低レベルのシステムコールのマニュアルです。

3.ライブラリコール(プログラムライブラリ内の関数)

  • 例:printf, malloc, socket
  • C標準ライブラリや他のプログラムライブラリ内の関数のマニュアルです。

4.特殊ファイル(通常 /dev にある)

  • 例:/dev/null, /dev/sda
  • デバイスファイルや特殊ファイルに関するマニュアルです。

5.ファイル形式と規約、例: /etc/passwd

  • 例:/etc/passwd, /etc/fstab
  • 各種設定ファイルやデータフォーマットに関するマニュアルです。

6.ゲーム

  • 例:nethack, fortune
  • ゲームや娯楽用プログラムのマニュアルです。

7.その他(マクロパッケージや規約を含む)

  • 例:man, groff
  • 他のカテゴリに属さないマニュアルページやマクロパッケージのマニュアルです。

8.システム管理コマンド(通常は root のみ)

  • 例:ifconfig, systemctl, mount
  • システム管理者向けのコマンドやユーティリティのマニュアルです。

9.カーネルルーチン [非標準]

  • 例:特定のカーネル内部の機能やルーチンに関するマニュアルです。
  • このセクションは非標準で、すべてのシステムで利用可能とは限りません。

6.別セクションを表示する

例えばchmodのマニュアルは通常であればchmod(1)しかありませんが、dnf install man-pagesをインストールすると、chmod(2)が見られるようになります。

同じコマンドで別のセクションのマニュアルページを開く場合は次のようにします。

man [セクション番号] [コマンド]

実行例

man 2 chmod
chmod(2)                                        System Calls Manual                                       chmod(2)

NAME
       chmod, fchmod, fchmodat - change permissions of a file

LIBRARY
       Standard C library (libc, -lc)

SYNOPSIS
       #include <sys/stat.h>

       int chmod(const char *pathname, mode_t mode);
       int fchmod(int fd, mode_t mode);

       #include <fcntl.h>           /* Definition of AT_* constants */
       #include <sys/stat.h>

       int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7))
...

7.manコマンドのオプション

manコマンドは-k,-l,-f,-Wのオプションが用意されています。

-kオプション

-kオプションでキーワード検索ができます。

[yoyo@AL ~]$ man -k chmod
chmod (1)            - change file mode bits
chmod (1p)           - change the file modes
chmod (2)            - change permissions of a file
chmod (3p)           - change mode of a file
fchmod (2)           - change permissions of a file
fchmod (3p)          - change mode of a file
fchmodat (2)         - change permissions of a file
fchmodat (3p)        - change mode of a file relative to directory file descriptor

-fオプション

-fオプションで、コマンドの簡易説明を表示する事ができます。

[yoyo@AL ~]$ man -f chmod
chmod (1)            - change file mode bits
chmod (1p)           - change the file modes
chmod (2)            - change permissions of a file
chmod (3p)           - change mode of a file

-wオプション

-wオプションで、コマンドのマニュアルファイルがある場所を表示できます。

[yoyo@AL ~]$ man -w chmod
/usr/share/man/man1/chmod.1.gz

-lオプション

-lオプションで、指定したディレクトリパスにあるmanファイルを開きます。

[yoyo@AL ~]$ man -l /usr/share/man/man1/chmod.1.gz
# /usr/share/man/man1/chmod.1.gzをディレクトリで指定して開いています。

8.その他

たまに忘れますが、sshd_configなど、コマンドではなくconfigファイルなどのマニュアルも用意されている事があるので、同様にして参照する事ができます。

man sshd_config
NAME
     sshd_config — OpenSSH daemon configuration file

DESCRIPTION
     sshd(8) reads configuration data from /etc/ssh/sshd_config (or the file specified with -f on the command
     line).  The file contains keyword-argument pairs, one per line.  For each keyword, the first obtained value
     will be used.  Lines starting with ‘#’ and empty lines are interpreted as comments.  Arguments may optionally
     be enclosed in double quotes (") in order to represent arguments containing spaces.

     The possible keywords and their meanings are as follows (note that keywords are case-insensitive and argu‐
     ments are case-sensitive):

     AcceptEnv
             Specifies what environment variables sent by the client will be copied into the session's environ(7).
             See SendEnv and SetEnv in ssh_config(5) for how to configure the client.  The TERM environment vari‐
             able is always accepted whenever the client requests a pseudo-terminal as it is required by the pro‐
             tocol.  Variables are specified by name, which may contain the wildcard characters ‘*’ and ‘?’.  Mul‐
             tiple environment variables may be separated by whitespace or spread across multiple AcceptEnv direc‐
             tives.  Be warned that some environment variables could be used to bypass restricted user environ‐
             ments.  For this reason, care should be taken in the use of this directive.  The default is not to
             accept any environment variables.
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0