Open gh-liu opened 3 months ago
/proc
linux
/proc 文件系统是一种伪文件系统(不对应真实的磁盘存储,而是内存中的一部分),为内核数据结构提供了一个接口 /proc 文件系统中的大多数文件是只读的(提供关于系统和内核的信息),但有些文件是可写的,允许更改内核变量(调优和实时控制内核行为)
man 5 proc
/proc/[pid]
/proc/self 访问当前进程的信息
/proc/self
cmdline
cwd
environ
exe
fd
maps
mem
mounts
root
status
task
/proc/[tid]
/proc/thread-self 访问当前线程的信息
/proc/thread-self
/proc下还有许多文件和文件夹暴露了系统级别的信息
/proc/net
/proc/sys/fs
/proc/sys/kernel
/proc/sys/net
/proc/sys/vm
/proc/sysvipc
/proc
oflinux
获取进程的信息
/proc/[pid]
cmdline
: Command-line arguments delimited by \0cwd
: Symbolic link to current working directoryenviron
: Environment list NAME=value pairs, delimited by \0exe
: Symbolic link to file being executedfd
: Directory containing symbolic links to files opened by this processmaps
: Memory mappingsmem
: Process virtual memory (must lseek() to valid offset before I/O)mounts
: Mount points for this processroot
: Symbolic link to root directorystatus
: Various information (e.g., process IDs, credentials, memory usage, signals)task
: Contains one subdirectory for each thread in process (Linux 2.6)获取线程的信息
/proc/[tid]
系统级别的信息
/proc
下还有许多文件和文件夹暴露了系统级别的信息/proc
: Various system information/proc/net
: Status information about networking and sockets/proc/sys/fs
: Settings related to file systems/proc/sys/kernel
: Various general kernel settings/proc/sys/net
: Networking and sockets settings/proc/sys/vm
: Memory-management settings/proc/sysvipc
: Information about System V IPC objects