这不是一个严重的问题,因为它可以通过重新启动来修复,但我很好奇是否有办法恢复 、和中的文件(可能不是全部/proc,但尽可能多)。/sys/dev/pts/dev
chroot当删除安装有这些目录的目录时,我部分删除了它们
mount -t proc proc [path/to/chroot]/proc
mount -t sysfs sys [path/to/chroot]/sys
mount --bind /dev/[path/to/chroot]/dev
mount -t devpts /dev/path [path/to/chroot]/dev/pts
Run Code Online (Sandbox Code Playgroud)
在 Ubuntu 16.10 amd64 上。某些文件的删除失败(我没有记录错误消息),因为文件删除被拒绝,这是我可以理解的。我想该解决方案将适用于所有基于 Debian 的系统。
退出后chroot我看到类似的事情
$ ls -bash: /dev/null: Keine Berechtigung
bash: _upvars: `-a2': invalid number specifier
-bash: /dev/null: Keine Berechtigung
bash: _upvars: `-a0': invalid number specifier
Run Code Online (Sandbox Code Playgroud)
在使用Tabon自动完成期间ls(导出后LANGUAGE=en)。
free我有一台主机,在比较命令的输出和 .txt 文件的内容时,我不确定内存利用率/proc/meminfo。缓冲区+缓存似乎在两个源之间不匹配。
[kbrandt@ny-chsearch01]~% free -k
total used free shared buff/cache available
Mem: 24506972 18074768 572836 124 5859368 5996392
Swap: 4194300 130044 4064256
[kbrandt@ny-chsearch01]~% cat /proc/meminfo
MemTotal: 24506972 kB
MemFree: 575808 kB
MemAvailable: 5996136 kB
Buffers: 3140 kB
Cached: 380032 kB
SwapCached: 61344 kB
Active: 16305144 kB
Inactive: 1860568 kB
Active(anon): 15990712 kB
Inactive(anon): 1791952 kB
Active(file): 314432 kB
Inactive(file): 68616 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 4194300 kB
SwapFree: 4064256 kB
Dirty: 24 kB …Run Code Online (Sandbox Code Playgroud) 当您查看/proc/net/tcp或/proc/net/tcp6文件时,您可以看到计算机本身打开的端口。
但只是想知道这些条目按什么顺序列出?
我正在尝试编写一个 1 行 bash 脚本,该脚本将获取看起来像内核进程的进程的所有 PID,并检查它们是否具有 中的内容/proc/*/maps,这表明内核进程伪装。
我目前有以下脚本:
for pid in $(ps aux | grep "\[" | awk -F' ' '{print $2}');do if [ -s /proc/$pid/maps ]; then echo $pid; fi; done
Run Code Online (Sandbox Code Playgroud)
/proc/$pid/maps如果size 大于 0,脚本应输出 pid。但是,脚本不输出任何内容。
if [ -s /proc/$pid/maps ]应该指示文件是否不为空。它似乎不起作用。
我可以使用另一种方法解决此问题,但-s互联网建议使用此选项来检查文件是否为空。
这里有什么问题吗?我确实知道有一个进程在其命令行(avahi 守护进程)中带有括号,该进程的内容将包含在 中/proc/$pid/maps,因此应该至少有 1 个 pid 输出用于测试目的。如果我从管道中删除 grep,那么它会迭代所有 pid,但仍然没有输出。
ls -rlth /proc/stat
-r--r--r-- 1 root root 0 Feb 21 04:25 /proc/stat
Run Code Online (Sandbox Code Playgroud)
虽然如果我们cat它,它有足够的内容。
查看 /proc/interrupts 下面的输出分别在第 26 行和第 27 行显示了 ERR 和 MIS。这些是什么?为什么它们有 CPU0 的计数(尽管为零)但没有其他计数,也没有描述?我认为它们实际上与 PIC 本身错误有关吗?
感谢 ErikF 的回复。为什么这些中断只出现在CPU0上?是否是因为如果 PIC/中断系统出现错误,只有该 CPU 才会收到中断?
1. username@domain:/proc$ cat interrupts
2. CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7
3. 0: 1221738 0 0 0 0 0 0 0 IO-APIC 2-edge timer
4. 1: 9 0 0 0 0 0 0 0 IO-APIC 1-edge i8042
5. 6: 3 0 0 0 0 0 0 0 IO-APIC 6-edge floppy
6. 8: 0 0 0 0 0 0 …Run Code Online (Sandbox Code Playgroud) 来自https://unix.stackexchange.com/a/492346/674
Linux 等内核和 BSD 内核通过
/proc和中的文件提供有关进程的四个(相关)信息sysctl():
- 它的程序映像简称,又名用于流程记账的简称;
- 它的参数字符串,由
execve()运行时初始化并可修改;- 它的环境字符串,由
execve()运行时初始化并可修改;和- 其可执行程序映像文件的完整路径名。
中的哪个文件/proc(以及 的哪些参数sysctl())提供了这四条信息中的每一条?谢谢。
我正在尝试验证为我的 Ubuntu 选择 Docker 容器映像文件时,我需要在它们之间匹配什么?
在 Lubuntu 上,一个 CentOS 容器说它是 CentOS,由
$ sudo docker run centos bash -c "cat /etc/*-release "
CentOS Linux release 7.6.1810 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
CentOS Linux release 7.6.1810 (Core)
CentOS Linux release 7.6.1810 (Core)
Run Code Online (Sandbox Code Playgroud)
但也说它与主机是相同的 Ubuntu:
$ sudo docker run centos bash -c "cat /proc/version"
Linux version 4.15.0-46-generic (buildd@lgw01-amd64-038) (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)) #49-Ubuntu SMP Wed …Run Code Online (Sandbox Code Playgroud) 我正在研究 Linux 中内存区域的虚拟内存映射。可执行文件是一个简单的计数程序。当程序的两个实例运行时,以下是 所示的映射/proc/pid/maps。堆、堆栈、vvar、vdso 等的位置在加载时似乎有随机偏移。为什么要这样做?
实例 1:堆开始于013f4000
00400000-00401000 r--p 00000000 08:16 3557412 <program-exe>
00401000-00480000 r-xp 00001000 08:16 3557412 <program-exe>
00480000-004a5000 r--p 00080000 08:16 3557412 <program-exe>
004a6000-004ac000 rw-p 000a5000 08:16 3557412 <program-exe>
004ac000-004ad000 rw-p 00000000 00:00 0
013f4000-01417000 rw-p 00000000 00:00 0 [heap]
7ffd98bd8000-7ffd98bf9000 rw-p 00000000 00:00 0 [stack]
7ffd98bfc000-7ffd98bff000 r--p 00000000 00:00 0 [vvar]
7ffd98bff000-7ffd98c00000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0 [vsyscall]
Run Code Online (Sandbox Code Playgroud)
实例2:堆开始于013cc000
00400000-00401000 r--p 00000000 08:16 3557412 <program-exe>
00401000-00480000 r-xp 00001000 …Run Code Online (Sandbox Code Playgroud) 这是脚本:
TYPE="${BLOCK_INSTANCE:-mem}"
awk -v type=$TYPE '
/^MemTotal:/ {
mem_total=$2
}
/^MemFree:/ {
mem_free=$2
}
/^Buffers:/ {
mem_free+=$2
}
/^Cached:/ {
mem_free+=$2
}
/^SwapTotal:/ {
swap_total=$2
}
/^SwapFree:/ {
swap_free=$2
}
END {
if (type == "swap") {
free=swap_free/1024/1024
used=(swap_total-swap_free)/1024/1024
total=swap_total/1024/1024
} else {
free=mem_free/1024/1024
used=(mem_total-mem_free)/1024/1024
total=mem_total/1024/1024
}
pct=used/total*100
# full text
printf("%.1fG/%.1fG (%.f%)\n", used, total, pct)
# short text
printf("%.f%\n", pct)
# color
if (pct > 90) {
print("#FF0000\n")
} else if (pct > 80) {
print("#FFAE00\n")
} else if …Run Code Online (Sandbox Code Playgroud)