Linux proc文件系统介绍

news2024/10/4 19:56:13

Linux proc文件系统

/proc/cmdline

Arguments  passed to the Linux kernel at boot time.  Often done via a boot manager such as lilo(8) or grub(8)


            

proc/[pid]/coredump_filter

      Since kernel 2.6.23, the Linux-specific /proc/PID/coredump_filter file can be used  to
       control  which  memory  segments are written to the core dump file in the event that a
       core dump is performed for the process with the corresponding process ID.

       The value in the file is a bit mask of memory mapping types (see mmap(2)).  If  a  bit
       is  set in the mask, then memory mappings of the corresponding type are dumped; other‐
       wise they are not dumped.  The bits in this file have the following meanings:

           bit 0  Dump anonymous private mappings.
           bit 1  Dump anonymous shared mappings.
           bit 2  Dump file-backed private mappings.
           bit 3  Dump file-backed shared mappings.
           bit 4 (since Linux 2.6.24)
                  Dump ELF headers.
           bit 5 (since Linux 2.6.28)
                  Dump private huge pages.
           bit 6 (since Linux 2.6.28)
                  Dump shared huge pages.


/proc/[pid]/environ

包含了该进程的环境变量。

/proc/[pid]/fd/

 /proc/interrupts

This is used to record the number of interrupts per CPU per IO  device.   Since Linux  2.6.24,  for  the  i386  and  x86_64  architectures, at least, this also includes interrupts internal to the system (that  is,  not  associated  with  a device  as  such), such as NMI (nonmaskable interrupt), LOC (local timer interrupt), and for SMP systems, TLB (TLB flush interrupt), RES (rescheduling interrupt), CAL (remote function call interrupt), and possibly others.  Very easy to read formatting, done in ASCII.

 /proc/kallsyms (since Linux 2.5.71)

这包含使用模块(X)工具导出的内核符号定义。包括动态地链接和绑定可加载的模块。在Linux 2.5.47及更早的版本中,类似文件被命名为ksyms。

/proc/kmsg

可以使用此文件来代替syslog (2)系统调用来读取内核消息。进程必须具有超级用户权限才能读取此文件,并且只有一个进程应该读取此文件。如果一个使用syslog (2)系统调用工具来记录内核消息的syslog进程正在运行,则不应该读取此文件。

使用dmesg命令可以获取文件中的信息。

/proc/sys/kernel/dmesg_restrict (since Linux 2.6.37)

控制谁可以看到dmesg信息。值为0表示不受控,所有用户都可以看到。值为1标志是有超级用户才能看到,从linux 3.4开始,只有系统管理员才能看到dmesg。

/proc/sys/kernel/domainname and /proc/sys/kernel/hostname 

              can  be  used  to  set  the  NIS/YP  domainname and the hostname of your box in
              exactly the same way as the commands domainname(1) and hostname(1), that is:

                  # echo 'darkstar' > /proc/sys/kernel/hostname
                  # echo 'mydomain' > /proc/sys/kernel/domainname

              has the same effect as

                  # hostname 'darkstar'
                  # domainname 'mydomain'

              Note, however, that the classic darkstar.frop.org has the  hostname  "darkstar"
              and DNS (Internet Domain Name Server) domainname "frop.org", not to be confused
              with the NIS (Network Information Service) or  YP  (Yellow  Pages)  domainname.
              These two domain names are in general different.  For a detailed discussion see
              the hostname(1) man page.

/proc/sys/kernel/hotplug

 This file contains the path for the hotplug policy agent.  The default value in this file is /sbin/hotplug.

/proc/sys/kernel/modprobe

                This file contains the path for the kernel module loader.  The default value is
              /sbin/modprobe.   The file is present only if the kernel is built with the CON‐
              FIG_MODULES (CONFIG_KMOD in Linux 2.6.26 and earlier) option  enabled.   It  is
              described  by the Linux kernel source file Documentation/kmod.txt (present only
              in kernel 2.4 and earlier).

/proc/sys/kernel/modules_disabled

一个切换值,指示是否允许加载模块,否则,模块既不能加载或卸载,切换不能加载

重新设置为false。只有当内核启用CONFIG_MODULES选项才有此选项。

/proc/sys/kernel/msgmax

定义消息队列一个消息的最大长度。

/proc/sys/kernel/msgmni

定义了消息队列的个数。

/proc/sys/kernel/msgmnb

此文件定义了一个系统范围内的参数,用于初始化随后创建的消息队列的msg_qbytes设置。msg_qbytes设置指定可以写入消息队列的最大字节数。

/proc/sys/kernel/panic 

此文件提供对内核变量panic_timeout的读写访问。如果这是零,内核panic的时候会死循环;如果为非零,则表示内核应该在这个秒数之后自动重新启动。当您使用软件看门狗设备驱动程序时,建议的设置为60。

/proc/sys/kernel/panic_on_oops

此文件控制在遇到oops或BUG时内核的行为。

如果它包含1,然后系统延迟几秒钟(给klogd时间来记录然后panic。如果/proc/sys/内核/panic文件也是非零,然后机器将被重新启动。

/proc/sys/kernel/pid_max 

定义了PID的最大值(该文件中的值比系统中最大PID大1)。该文件的默认值32768的结果范围与之前的内核相同。在32位平台上,32768是pid_max的最大值。在64位系统上,pid_max可以设置为高达2^22(PID_MAX_LIMIT,大约400万)的任何值。

 

/proc/sys/kernel/printk

这四个值分别代表:console_loglevel,  default_message_loglevel, minimum_console_level,  and  default_console_loglevel.

 These values influence printk() behavior when printing or logging error messages.

优先级高于console_loglevel的消息将被打印到控制台。没有显式优先级的消息将被打印为优先级默认消息级别。minimum_console_loglevel是console_loglevel可以设置到的最小(最高)值。default_console_loglevel是console_loglevel的默认值。

/proc/sys/kernel/real-root-dev

/proc/sys/kernel/sysrq

This  file  controls  the functions allowed to be invoked by the SysRq key.  By default, the file contains 1 meaning  that  every  possible  SysRq  request  is allowed。

/proc/sys/vm/panic_on_oom (since Linux 2.6.18)

             This enables or disables a kernel panic in an out-of-memory situation.

              If this file is set to the value 0, the  kernel's  OOM-killer  will  kill  some
              rogue process.  Usually, the OOM-killer is able to kill a rogue process and the
              system will survive.

              If this file is set to the value 1, then the kernel normally panics  when  out-
              of-memory  happens.   However, if a process limits allocations to certain nodes
              using memory policies (mbind(2) MPOL_BIND) or  cpusets  (cpuset(7))  and  those
              nodes  reach  memory  exhaustion  status, one process may be killed by the OOM-
              killer.  No panic occurs in this case: because other nodes' memory may be free,
              this  means  the system as a whole may not have reached an out-of-memory situa‐
              tion yet.

              If this file is set to the value 2, the kernel always panics  when  an  out-of-
              memory condition occurs.

              The default value is 0.  1 and 2 are for failover of clustering.  Select either
              according to your policy of failover.

 /proc/sysrq-trigger

怎么触发一个sysrq事件?

如果你在机器上有root权限,你能把commandkey字符写入到/proc/sysrq-trigger文件。这能帮助你通过脚本或你不在系统终端上的时候触发sysrq事件。

echo ‘m’ > /proc/sysrq-trigger

当我触发一个sysrq事件的时候,结果保存在什么地方?

当一个sysrq命令被触发,内核将会打印信息到内核的环形缓冲并输出到系统控制台。此信息一般也会通过syslog输出到/var/log/messages。

sysrq功能被打开后,有几种sysrq事件能被触发。不同的内核版本可能会有些不同。但有一些是共用的:

m - 导出关于内存分配的信息,

t - 导出线程状态信息,

p - 导出当前CPU寄存器信息和标志位的信息,

c - 故意让系统崩溃(在使用netdump或diskdump的时候有用),

s - 即时同步所有挂载的文件系统,

u - 即时重新挂载所有的文件系统为只读,

b - 即时重新启动系统,

o - 即时关机(如果机器设置并支持此项功能)。

立即重新启动计算机

echo “b” > /proc/sysrq-trigger

立即关闭计算机

echo “o” > /proc/sysrq-trigger

导出内存分配的信息 (可以用/var/log/message 查看)

echo “m” > /proc/sysrq-trigger

导出当前CPU寄存器信息和标志位的信息

echo “p” > /proc/sysrq-trigger

导出线程状态信息

echo “t” > /proc/sysrq-trigger

故意让系统崩溃

echo “c” > /proc/sysrq-trigger

立即重新挂载所有的文件系统

echo “s” > /proc/sysrq-trigger

立即重新挂载所有的文件系统为只读

echo “u” > /proc/sysrq-trigger

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/421550.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

大数据项目实战之数据仓库:电商数据仓库系统——第6章 数据仓库环境准备

第6章 数据仓库环境准备 6.1 数据仓库运行环境 6.1.1 Hive环境搭建 1)Hive引擎简介 Hive引擎包括:默认MR、Tez、Spark。 Hive on Spark:Hive既作为存储元数据又负责SQL的解析优化,语法是HQL语法,执行引擎变成了Sp…

【收藏】2023欧洲 KubeCon 和云原生大会上关于WebAssembly的一切

KubeCon CloudNativeCon EU 2023将于4月18日至21日在阿姆斯特丹举行,对于云原生开发者和云原生用户是一年中无比期待的大会。会议为期四天,是保持云原生计算最新趋势,与同行建立联系,并从行业专家学习的绝佳机会。此外&#xff0…

2023年税务师事务所行业研究报告

第一章 行业发展概况 1.1 行业概况 税务师事务所是依法设立并承办法律、法规、规章规定的涉税服务和鉴证业务的社会中介机构。税务师事务所的组织形式为有限责任制税务师事务所和合伙制税务师事务所,以及国家税务总局规定的其他形式。税务师事务所应当依法纳税&am…

软件测试实验:静态测试

目录 前言 一、实验目的 二、实验内容 三、实验步骤 四、实验过程 1、学生宿舍管理系统代码 2、汇总表 3、C语言编码规范 总结 前言 软件测试是软件开发过程中不可或缺的一个环节,它可以保证软件的质量和功能,提高用户的满意度和信任度。软件测…

通信工程有哪些SCI期刊推荐? - 易智编译EaseEditing

以下是通信工程领域的一些SCI期刊推荐: IEEE Transactions on Communications: 该期刊由IEEE出版,是通信工程领域的顶级期刊,涵盖了通信系统、信号处理、无线通信、光通信、网络通信、通信安全等方面的研究。 IEEE Journal on S…

如何使用公网远程访问jupyter notebook【cpolar内网穿透】

文章目录前言视频教程1. Python环境安装2. Jupyter 安装3. 启动Jupyter Notebook4. 远程访问4.1 安装配置cpolar内网穿透4.2 创建隧道映射本地端口5. 固定公网地址转载自远控源码文章:公网远程访问jupyter notebook【cpolar内网穿透】 前言 Jupyter Notebook&#…

【Redis】多级缓存

【Redis】多级缓存 文章目录【Redis】多级缓存1. 传统缓存的问题2. 多级缓存方案2.1 JVM进程缓存2.1.1 本地进程缓存2.1.2 Caffeine2.2 Nginx缓存2.2.1 准备工作2.2.21. 传统缓存的问题 传统的缓存策略一般是请求到达 tomcat 后,先查询redis,如果未命中…

微服务高级篇【3】之分布式缓存Redis集群

文章目录前言一 单机Redis存在的问题二 Redis的安装三 Redis持久化3.1 RDB持久化3.1.1 触发条件3.1.2 RDB原理3.1.3 小结3.2 AOF持久化3.2.1 AOF原理3.2.2 AOF配置3.2.3 AOF文件重写3.3 RDB与AOF对比四 Redis主从集群4.1 搭建主从架构4.2 搭建主从集群4.2.1 集群结构4.2.2 准备…

【FFmpeg】自定义编码器适配

目录1 编码流程1.1 整体流程1.2 内部流程2 适配接口2.1 init、close2.2 option2.3 receive2.4 encode2.5 零拷贝的设计1 编码流程 FFmpeg是一个开源的多媒体框架,底层可对接实现多种编解码器,下面参考文件doc/examples/encode_video.c分析编码一帧的流程…

Adobe Illustrator2023(AI2023)图文安装教程

Adobe Illustrator2023(AI2023)简称AI,是一种应用于出版、多媒体和在线图像的工业标准矢量插画的软件。该软件主要应用于印刷出版、海报书籍排版、专业插画、多媒体图像处理和互联网页面的制作等,也可以为线稿提供较高的精度和控制,适合生产任…

【Camunda】 -- Docker 安裝及使用

【Camunda】 -- Docker 安裝及使用1. Docker install Camunda platform1.1 Web2. Big Data -- Postgres1.1 Big Data -- Postgres3.Awakening1.1 Big Data -- PostgresCamunda platform 是一個任務監控的平台。 Camunda Modeler是建模工具。 1. Docker install Camunda platfor…

【超详细教程】解决libxxx.so: cannot open shared object file: No file or directory

一、参考资料 error while loading shared libraries的解决方案 libascend_hal.so: cannot open shared object file:No such…解决办法-云社区-华为云 (huaweicloud.com) 二、相关介绍 1. -lxxx.so命名 lxxx means lib lib-name .solc means libc.so, lltdl means lib…

C++学习从基础到高阶(基于黑马程序员教程)

视频链接:黑马程序员匠心之作|C教程从0到1入门编程,学习编程不再难(52个小时) C语言中文网:http://c.biancheng.net/cplus/ Visual Studio 2022 下载地址:https://visualstudio.microsoft.com/zh-hans/downloads/ Visu…

软件设计模式 | 动态代理模式

文章目录一、动态代理概述1.1 代理的概述和作用1.2 动态代理的优点1.3 代理对象的创建1.4 代理对象调用方法的执行流程二、动态代理举例2.1 歌手经纪人2.2 业务功能的性能统计2.3 动态代理在 Spring 框架中的应用三、基于子类的动态代理一、动态代理概述 1.1 代理的概述和作用…

英语语法——动词

文章目录分类时态一般时态三单过去式进行时态现在分词完成时态过去分词完成进行时态情态语态否定强调非谓语动词分类 时态 时态用于表示动作发生的时间和状态,它通过谓语动词的形式变化来体现,时态是每个动词必须要有的。在英语中有以下十六种时态&…

MySQL怎么卸载干净

卸载干净MySQL的步骤:首先关闭MySQL服务;然后卸载MySQL软件;接着删除MySQL在电脑中的残存文件;最后删除MySQL注册表信息即可。 很多人都遇到过一个问题,那就是在安装MySQL的时候操作错误,最后结果不是自己想…

C++【深入理解继承】

文章目录一、继承概念与定义二、基类和派生类对象赋值转换三、派生类的默认成员函数(1)构造函数(2)拷贝构造函数(3)赋值重载(4)析构函数四、复杂的菱形继承及菱形虚拟继承&#xff0…

python 不指定参数个数---args基础用法

前言: 在有些时候,设计函数的时候,可能不知道要传入的参数类型或者参数个数,此时args可以很好地解决。 一、*args的基本用法 1。传入不指定个数的参数, 2。参数的类型也不指定,可以是任意类型数据&…

k8s学习(三十五)飞腾2000+麒麟V10离线部署metrics-server

文章目录1、下载metrics-server配置文件2、下载推送metrics-server镜像3、修改metrics-server配置4、启动metrics-server1、下载metrics-server配置文件 在有网机器上从网站https://github.com/kubernetes-incubator/metrics-server下载 拷贝其到离线机器K8S的master节点。 2…

九龙证券|又3个涨停,退市风险急升!

*ST新海退市危险急剧上升! 到4月14日,*ST新海收盘价接连14个买卖日低于1元/股。按照退市新规,若*ST新海在接下来6个买卖日收盘价继续低于1元/股,将触及买卖类强制退市景象而终止上市,公司股票将不进入退市整理期。 面…