「Procfs」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(英語版より記事を転載)
 
(序文を翻訳)
3行目: 3行目:
 
{{Style|Use [[Template:ic]].}}
 
{{Style|Use [[Template:ic]].}}
   
The proc file system, also called [[Wikipedia:procfs|procfs]], is a pseudo file system that is usually mounted at {{ic|/proc}} and contains information about the running system:
+
proc ファイルシステム、または [[Wikipedia:procfs|procfs]] は擬似ファイルシステムで、通常 {{ic|/proc}} にマウントされ、実行中のシステムに関する情報を含んでいます。
   
  +
* プロセス、最も顕著な使用例。
* Processes, the most prominent use.
 
* Kernel information and [[sysctl|parameters]].
+
* カーネル情報および [[sysctl|パラメータ]]
  +
* システムメトリクス、たとえば CPU 使用率。
* System metrics, such as CPU usage.
 
   
 
== Content ==
 
== Content ==

2023年8月30日 (水) 19:14時点における版

この記事あるいはセクションで使われている用語や表現には問題が存在します。
議論: Use Template:ic. (議論: トーク:Procfs#)

proc ファイルシステム、または procfs は擬似ファイルシステムで、通常 /proc にマウントされ、実行中のシステムに関する情報を含んでいます。

  • プロセス、最も顕著な使用例。
  • カーネル情報および パラメータ
  • システムメトリクス、たとえば CPU 使用率。

Content

Kernel & system information

There are many files under /proc which provide a lot of information about the system as well as the kernel. There are too many to cover them all here, but some of them are listed below with brief information about what they are.

  • /proc/cpuinfo - informations about CPU
  • /proc/meminfo - information about the physical memory
  • /proc/vmstats - information about the virtual memory
  • /proc/mounts - information about the mounts
  • /proc/filesystems - information about filesystems that have been compiled into the kernel and whose kernel modules are currently loaded
  • /proc/uptime - current system uptime
  • /proc/cmdline - kernel command line

Processes

Inside /proc/pid is stored information about every process currently running. Below is an example showing some of the PIDs currently running:

$ ls -l /proc
total 0
dr-xr-xr-x  9 root    root                  0 Sep  8 18:17 1
dr-xr-xr-x  9 root    root                  0 Sep  9 03:02 10
dr-xr-xr-x  9 daemonx daemonx               0 Sep  9 03:02 1057
dr-xr-xr-x  9 daemonx daemonx               0 Sep  8 18:18 1077
dr-xr-xr-x  9 daemonx daemonx               0 Sep  9 03:02 1087
dr-xr-xr-x  9 root    root                  0 Sep  9 03:02 11
dr-xr-xr-x  9 daemonx daemonx               0 Sep  9 03:02 1103
dr-xr-xr-x  9 daemonx daemonx               0 Sep  9 03:02 1107
dr-xr-xr-x  9 daemonx daemonx               0 Sep  9 03:02 1159
dr-xr-xr-x  9 root    root                  0 Sep  9 03:02 12
dr-xr-xr-x  9 root    root                  0 Sep  9 03:02 124
dr-xr-xr-x  9 root    root                  0 Sep  9 03:02 125
dr-xr-xr-x  9 root    root                  0 Sep  9 03:02 127
dr-xr-xr-x  9 root    root                  0 Sep  9 03:02 128
...

Lets take for example pid 1057 and see what is inside:

$ ls -l /proc/1057
total 0
dr-xr-xr-x 2 daemonx daemonx 0 Sep  9 03:12 attr
-rw-r--r-- 1 daemonx daemonx 0 Sep  9 03:12 autogroup
-r-------- 1 daemonx daemonx 0 Sep  9 03:12 auxv
-r--r--r-- 1 daemonx daemonx 0 Sep  9 03:12 cgroup
--w------- 1 daemonx daemonx 0 Sep  9 03:12 clear_refs
-r--r--r-- 1 daemonx daemonx 0 Sep  9 03:12 cmdline
-rw-r--r-- 1 daemonx daemonx 0 Sep  9 03:12 comm
-rw-r--r-- 1 daemonx daemonx 0 Sep  9 03:12 coredump_filter
-r--r--r-- 1 daemonx daemonx 0 Sep  9 03:12 cpuset
lrwxrwxrwx 1 daemonx daemonx 0 Sep  9 03:12 cwd -> /home/daemonx
-r-------- 1 daemonx daemonx 0 Sep  9 03:12 environ
lrwxrwxrwx 1 daemonx daemonx 0 Sep  9 03:12 exe -> /usr/lib/gvfsd-metadata
dr-x------ 2 daemonx daemonx 0 Sep  9 03:12 fd
dr-x------ 2 daemonx daemonx 0 Sep  9 03:12 fdinfo
-rw-r--r-- 1 daemonx daemonx 0 Sep  9 03:12 gid_map
-r-------- 1 daemonx daemonx 0 Sep  9 03:12 io
-r--r--r-- 1 daemonx daemonx 0 Sep  9 03:12 latency
-r--r--r-- 1 daemonx daemonx 0 Sep  9 03:12 limits
-rw-r--r-- 1 daemonx daemonx 0 Sep  9 03:12 loginuid
dr-x------ 2 daemonx daemonx 0 Sep  9 03:12 map_files
-r--r--r-- 1 daemonx daemonx 0 Sep  9 03:12 maps
-rw------- 1 daemonx daemonx 0 Sep  9 03:12 mem
...

Some of the fields:

  • cmdline - arguments used to start program.
  • cwd - current working directory for the process.
  • environ - environment variables inside the process (zero-delimited).
  • fd/ - directory containing open file descriptors for the process.
  • exe - symbolic link to process executable.
  • maps - memory mapping of the process.
  • mem - virtual memory of the process.

Usage

You can interact with /proc contents as with regular files.

To read from a file:

$ cat /proc/cmdline

To write to a file:

# echo 1 > /proc/sys/kernel/sysrq

See also