Linux 查看进程启动时的环境变量值

Linux About 626 words

环境变量文件

cat /proc/[pid]/environ

示例

Kubernetes容器中的进程ID一般为1

cat /proc/1/environ

输出

PATH=/usr/java/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binHOSTNAME=xxxJDK_JAVA_OPTIONS=-XX:NativeMemoryTracking=detailJAVA_HOME=/usr/java/openjdk-11LANG=C.UTF-8JAVA_VERSION=11.0.2.1HOME=/

输出都在一行,不太友好

cat /proc/1/environ | tr '\000' '\n'

输出

bash-4.4$ cat /proc/1/environ | tr '\000' '\n'
PATH=/usr/java/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=xxx
JDK_JAVA_OPTIONS=-XX:NativeMemoryTracking=detail
JAVA_HOME=/usr/java/openjdk-11
LANG=C.UTF-8
JAVA_VERSION=11.0.2.1
HOME=/
Views: 597 · Posted: 2023-07-25

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh