AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-128739

Shuzheng's questions

Martin Hope
Shuzheng
Asked: 2023-08-24 22:35:22 +0800 CST

为什么`找到. -type d -not -perm 775` 打印具有 `rwxr-xr-x` 权限的目录?

  • 2

我想查找没有特定权限集的所有目录。如下图所示,find打印出不应列出的目录。

有人可以描述为什么吗?

在此输入图像描述

find
  • 1 个回答
  • 53 Views
Martin Hope
Shuzheng
Asked: 2023-05-22 20:36:04 +0800 CST

为什么 Bash 在将 stdout 重定向到 stderr 两次(`>&2` 和 `>/dev/stderr`)时输出两行?

  • 5

为什么以下输出重定向会导致打印两行?

将>&2stdout 复制到 stderr,>/dev/stderr并将 stdout 重定向到 stderr。

我希望只有一个输出行,因为echo foo输出被重定向到 stderr。

为什么我看不到两个输出行:echo foo >/dev/stderr 2>&1和echo foo >/dev/stdout 2>&1?

➜  app git:(python3.10-pipeline) ✗ echo foo >/dev/stderr >&2
foo
foo
➜  app git:(python3.10-pipeline) ✗ echo foo >/dev/stdout >&2
foo
foo
bash
  • 1 个回答
  • 43 Views
Martin Hope
Shuzheng
Asked: 2023-04-04 16:56:09 +0800 CST

使用“Bash 严格模式”时如何解析 Bash 脚本的位置参数?

  • 7

Bash 严格模式定义如下:

#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

http://redsymbol.net/articles/unofficial-bash-strict-mode/

考虑以下 Bash 脚本中位置参数的解析:

#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

usage() {
  echo ""
  echo "usage:"
  echo "$0 [options]"
  echo "  -r | --redirect-uri:  redirect uri"
  echo "  -a | --app-role:      app role id"
  echo "  -h | --help:          help"
  echo ""
}

redirect_uri=""
app_role=""

while [ "$1" != "" ]; do
  case $1 in
  -r | --redirect-uri)
    shift
    redirect_uri="$1"
    ;;
  -a | --app-role)
    shift
    app_role="$1"
    ;;
  -h | --help)
    usage
    exit 0
    ;;
  *)
    usage
    exit 1
    ;;
  esac
  shift
done

...

这不适用于以下错误,例如:

$ ./app.sh -r https://example.net:8080/auth/callback -a 53b37b21-2c6e-4731-a5e5-15b98052c686        
./app.sh: line 18: $1: unbound variable

我认为原因是条件的最终检查while, after shift, where$1是未定义的。

使用 Bash 严格模式时,如何在while不导致脚本崩溃的情况下终止语句中的参数解析?

bash
  • 1 个回答
  • 135 Views
Martin Hope
Shuzheng
Asked: 2021-10-28 01:20:58 +0800 CST

当内核被映射到与进程本身相同的虚拟地址空间时,为什么需要 `copy_from_user()` 和 `copy_to_user()`?

  • 2

当内核映射到与进程本身相同的虚拟地址空间时,为什么需要copy_from_user()并且需要?copy_to_user()

在为学习目的开发了一些(玩具)内核模块后,我很快意识到了这一点,copy_from_user()并且copy_to_user()需要将数据从用户空间缓冲区复制到用户空间缓冲区;否则与无效地址相关的错误会导致崩溃。

但是,如果0x1fffff虚拟地址指向用户空间缓冲区,那么为什么该地址在内核中无效?内核位于相同的虚拟地址空间中,因此0x1fffff将映射到相同的物理内存。

在此处输入图像描述

在此处输入图像描述

kernel drivers
  • 1 个回答
  • 1133 Views
Martin Hope
Shuzheng
Asked: 2021-10-23 02:47:56 +0800 CST

为 Debian 和其他发行版手动安装新内核是否安全?

  • 0

使用以下命令从kernel.org手动编译和安装新内核通常是否安全:

make -j 8
make install 
make modules_install

或者发行版(例如 Debian)可能会中断,因为它假定它通过 管理内核升级apt?

直观地说,一切都应该继续工作,因为内核保留了稳定的系统调用 API,并且驱动程序与早期版本兼容。

debian kernel
  • 1 个回答
  • 88 Views
Martin Hope
Shuzheng
Asked: 2021-10-06 00:46:12 +0800 CST

自定义“PT_INTERP”解释器导致分段错误?

  • 1

在阅读了这篇关于通过更改为自定义解释器来执行任意程序的文章后PT_INTERP,我尝试在本地进行实验:

$ cat flag.c
#include <stdio.h>

int main(int argc, char **argv) {
    printf("Hello World!\n");
    return 0;
}
$ gcc -static flag.c -o flag
$ cat solution.c
const char interp_section[] __attribute__((section(".interp"))) = "./flag";
$ gcc -s -fno-ident -Wl,--build-id=none -Wl,-e,0 -static -nostdlib solution.c -o solution
$ ./solution
Segmentation fault
$ ./flag
Hello World!

这个PT_INTERP程序头包含一个路径,也就是我们的ELF将在其下运行的解释器(可执行文件)的路径

既然solutionrequests./flag作为它的解释器,为什么不./flag运行并打印消息“Hello World”,什么时候solution执行?而是发生了分段错误,这与文章中的行为不同。

如何在 中成功注册和执行自定义解释器PT_INTERP?

$ readelf -l solution

Elf file type is EXEC (Executable file)
Entry point 0x0
There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000400040 0x0000000000400040
                 0x00000000000000e0 0x00000000000000e0  R      0x8
  INTERP         0x0000000000000120 0x0000000000400120 0x0000000000400120
                 0x0000000000000007 0x0000000000000007  R      0x1
      [Requesting program interpreter: ./flag]
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x0000000000000127 0x0000000000000127  R      0x1000
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0x10

 Section to Segment mapping:
  Segment Sections...
   00
   01     .interp
   02     .interp
   03
linux debian
  • 1 个回答
  • 193 Views
Martin Hope
Shuzheng
Asked: 2021-09-14 00:34:59 +0800 CST

如何为`ps`设置“无限”屏幕宽度以防止它截断输出?

  • 0

ps当标准输出是一个终端以适应终端的宽度时截断输出。

我从中看到了ps --help output分别用于控制屏幕宽度和高度的ps支持--width和选项。--lines

我发现指定一个大的任意数字(如 )很尴尬--width 1000,那么是否有一些值或选项可以设置“无限”屏幕宽度?

root@controlplane:~# apt list --installed procps
Listing... Done
procps/now 2:3.3.12-3ubuntu1.2 amd64 [installed,local]

额外:是否可以使用搜索模式-C <cmd>来避免cmd逐字输入?

例子

root@controlplane:~# ps -f -C kubelet 
UID        PID  PPID  C STIME TTY          TIME CMD
root      9231     1  0 08:20 ?        00:00:07 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/
root@controlplane:~# ps -f -C kubelet | cat
UID        PID  PPID  C STIME TTY          TIME CMD
root      9231     1  0 08:20 ?        00:00:08 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --network-plugin=cni --pod-infra-container-image=k8s.gcr.io/pause:3.2
linux debian
  • 2 个回答
  • 189 Views
Martin Hope
Shuzheng
Asked: 2020-03-01 09:42:26 +0800 CST

如何在`/proc/1/ns/{ns}`中查看设备的设备号?

  • 2

如何查看设备的设备号/proc/1/ns/{ns}?

我已经阅读了 Go 库的代码(见下文),其中指出可以确定容器是否在主机命名空间中:未命名空间的设备号/proc/1/ns/{ns}是 4,其他任何东西都更高。

现在,在没有用户命名空间或 cgroup 的新 Debian 容器中,我运行以下命令:

root@54d74f795843:/# ls -la /proc/1/ns
total 0
dr-x--x--x 2 root root 0 Feb 29 17:18 .
dr-xr-xr-x 9 root root 0 Feb 29 17:18 ..
lrwxrwxrwx 1 root root 0 Feb 29 17:18 cgroup -> 'cgroup:[4026531835]'
lrwxrwxrwx 1 root root 0 Feb 29 17:18 ipc -> 'ipc:[4026532290]'
lrwxrwxrwx 1 root root 0 Feb 29 17:18 mnt -> 'mnt:[4026532288]'
lrwxrwxrwx 1 root root 0 Feb 29 17:18 net -> 'net:[4026532293]'
lrwxrwxrwx 1 root root 0 Feb 29 17:18 pid -> 'pid:[4026532291]'
lrwxrwxrwx 1 root root 0 Feb 29 17:18 user -> 'user:[4026531837]'
lrwxrwxrwx 1 root root 0 Feb 29 17:18 uts -> 'uts:[4026532289]'

这里的 4026531837 是什么'user:[4026531837]'意思?我不能是设备号,因为容器使用与主机相同的用户命名空间(我已经验证过)。

如何列出文件的设备号/proc/1/ns/{ns}?该ls -la命令显示这些文件是符号链接,那么它们怎么会有设备号呢?

amicontained/vendor/github.com/jessfraz/bpfd/proc/proc.go/

// HasNamespace determines if a container is using a particular namespace or the
// host namespace.
// The device number of an unnamespaced /proc/1/ns/{ns} is 4 and anything else is
// higher.
// Only works from inside a container.
func HasNamespace(ns string) (bool, error) {
    file := fmt.Sprintf("/proc/1/ns/%s", ns)

    // Use Lstat to not follow the symlink.
    var info syscall.Stat_t
    if err := syscall.Lstat(file, &info); err != nil {
        return false, &os.PathError{Op: "lstat", Path: file, Err: err}
    }

    // Get the device number. If it is higher than 4 it is in a namespace.
    if info.Dev > 4 {
        return true, nil
    }

    return false, nil
}
debian devices
  • 1 个回答
  • 527 Views
Martin Hope
Shuzheng
Asked: 2020-02-18 00:06:33 +0800 CST

`tmux` 是否通过命令模式支持任何帮助文档,例如 `vim`s `:help`?

  • 1

是否tmux支持通过命令模式 ( C-b :) 之类vim的任何帮助文档:help?

我经常想显示特定tmux命令的帮助文档,例如kill-window,至少包括命令的参数。

我可以在tmux不查阅man页面或在线文档的情况下显示此类信息吗?

linux tmux
  • 1 个回答
  • 39 Views
Martin Hope
Shuzheng
Asked: 2020-01-23 23:38:17 +0800 CST

Bash 中字符串的定义是什么?

  • 0

Bash 中字符串的定义是什么?

Bash 在其文档中的多个地方使用了术语“字符串”,例如记录=~用于正则表达式匹配的运算符:

额外的二元运算符 =~ 可用,其优先级与 == 和 != 相同。使用时,运算符右侧的字符串被视为 POSIX 扩展正则表达式并进行相应匹配(如在 regex(3) 中)。

在 sectionDEFINITIONS中,我没有看到任何字符串定义:

DEFINITIONS
       The following definitions are used throughout the rest of this document.
       blank  A space or tab.
       word   A sequence of characters considered as a single unit by the shell.  Also known as a token.
       name   A word consisting only of alphanumeric characters and underscores, and beginning with an alphabetic character or an underscore.  Also referred to as an identifier.
       metacharacter
              A character that, when unquoted, separates words.  One of the following:
              |  & ; ( ) < > space tab newline
       control operator
              A token that performs a control function.  It is one of the following symbols:
              || & && ; ;; ;& ;;& ( ) | |& <newline>

那么,Bash 中的字符串到底是什么?它们可以在IFS环境变量中包含空格或字符吗?

注意:我知道字符串通常被定义为字母表中的一系列符号。

bash debian
  • 1 个回答
  • 292 Views
Martin Hope
Shuzheng
Asked: 2020-01-18 09:19:45 +0800 CST

为什么“${ARRAY[@]}”被引用时会扩展为多个单词?

  • 2

我不明白为什么"${ARRAY[@]}"在引用()时会扩展到多个单词"..."?

举个例子:

IFS=":" read -ra ARRAY <<< "foo:bar:baz"
for e in "${ARRAY[@]}"; do echo $e; done
foo
bar
baz

我在引号中扩展的任何其他变量,比如"${VAR}",都会产生一个单词:

VAR="foo bar baz"
for a in "${VAR}"; do echo $a; done
foo bar baz

任何人都可以向 Linux 新手解释这一点吗?

bash variable
  • 1 个回答
  • 1072 Views
Martin Hope
Shuzheng
Asked: 2019-12-20 03:16:22 +0800 CST

tmux:通过键绑定更改选项的值时,如何显示选项的新值?

  • 1

我创建了以下键绑定来同步窗口中的所有窗格,以便我可以同时将clear它们全部同步:

bind C-s setw synchronize-panes \; display-message "█▓░ synchronize"

键绑定简单地否定synchronize-panes窗口选项的值:“on”或“off”。

虽然,按键绑定有效,但我有点完美主义,所以我想display-message展示"█▓░ synchronize {new-option-value}".

这可能吗?

linux terminal
  • 1 个回答
  • 91 Views
Martin Hope
Shuzheng
Asked: 2019-12-19 02:11:32 +0800 CST

如何使用 `apt` 查看软件包何时发布/更新?

  • 4

我想使用 安装“文件”包apt,因为我的 Docker 容器缺少该file命令。在安装之前,我正在检查包的详细信息(见下文)。

如何查看这些软件包的发布/更新日期?他们的描述说他们得到了 5 年的支持,但这没有任何意义,当我看不到它们何时发布/更新时?

另外,为什么要apt列出两个“文件”包?当我运行时,将安装其中哪一个apt install file?

root@eca1fcd5655a:/mnt/dotnetcore# apt show -a file
Package: file
Version: 1:5.32-2ubuntu0.3
Priority: important
Section: utils
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 81.9 kB
Depends: libc6 (>= 2.4), libmagic1 (= 1:5.32-2ubuntu0.3)
Homepage: http://www.darwinsys.com/file/
Task: minimal
Supported: 5y
Download-Size: 22.1 kB
APT-Sources: http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
Description: Recognize the type of data in a file using "magic" numbers

Package: file
Version: 1:5.32-2
Priority: important
Section: utils
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 81.9 kB
Depends: libc6 (>= 2.4), libmagic1 (= 1:5.32-2)
Homepage: http://www.darwinsys.com/file/
Task: minimal
Supported: 5y
Download-Size: 22.1 kB
APT-Sources: http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages
Description: Recognize the type of data in a file using "magic" numbers
debian files
  • 1 个回答
  • 1009 Views
Martin Hope
Shuzheng
Asked: 2019-10-25 23:07:46 +0800 CST

如何在手册页中查找文本?

  • -1

我发现在命令行的手册页中使用 grep 查找文本很有用,例如特定选项。

但是,grep在手册页上操作时无法按预期工作,如下所示,其中模式"-f"仅匹配"-"而模式"--file"不匹配(alias grep='grep --color=always'):

nlykkei-mbp:~ nlykkei$ alias grep
alias grep='grep --color=always'
nlykkei-mbp:~ nlykkei$ man grep | grep -e "-f"
          [-e pattern] [-f file] [--binary-files=value] [--color[=when]]
     -F, --fixed-strings
     -f file, --file=file
     -h, --no-filename
             --binary-file=without-match option.
     -L, --files-without-match
     -l, --files-with-matches
     --binary-files=value
     and the behaviour of the -f flag when used with an empty pattern file is
nlykkei-mbp:~ nlykkei$ man grep | grep -e "--file"
nlykkei-mbp:~ nlykkei$ echo "--file" | grep -e "--file"
--file
nlykkei-mbp:~ nlykkei$ ▒ 

相反,匹配管道文本echo按预期工作,那么这与手册页的“不可见”格式有关吗?是否可以在手册页中可靠 grep 文本?

注意:我知道man -kand man -K,但这些并不能完全解决我想要实现的目标。

linux
  • 2 个回答
  • 1137 Views
Martin Hope
Shuzheng
Asked: 2019-09-24 03:55:08 +0800 CST

动态链接器/加载器本身如何按照“文件”的报告进行动态链接?

  • 15

考虑 的共享对象依赖关系/bin/bash,其中包括/lib64/ld-linux-x86-64.so.2(动态链接器/加载器):

ldd /bin/bash
    linux-vdso.so.1 (0x00007fffd0887000)
    libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f57a04e3000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f57a04de000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f57a031d000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f57a0652000)

检查/lib64/ld-linux-x86-64.so.2表明它是一个符号链接/lib/x86_64-linux-gnu/ld-2.28.so:

ls -la /lib64/ld-linux-x86-64.so.2 
lrwxrwxrwx 1 root root 32 May  1 19:24 /lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.28.so

此外,file报告/lib/x86_64-linux-gnu/ld-2.28.so自身是动态链接的:

file -L /lib64/ld-linux-x86-64.so.2
/lib64/ld-linux-x86-64.so.2: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped

我想知道:

  1. 动态链接器/加载器 ( /lib64/ld-linux-x86-64.so.2) 本身如何动态链接?它是否在运行时链接自身?
  2. /lib/x86_64-linux-gnu/ld-2.28.so记录处理 a.out 二进制文件(man ld.so),但是/bin/bashELF 可执行文件吗?

程序 ld.so 处理 a.out 二进制文件,这是一种很久以前使用的格式;ld-linux.so*(/lib/ld-linux.so.1 用于 libc5,/lib/ld-linux.so.2 用于 glibc2)处理 ELF,每个人都已经使用多年了。

linux
  • 2 个回答
  • 2535 Views
Martin Hope
Shuzheng
Asked: 2019-09-24 00:54:21 +0800 CST

为什么 `chroot` 操作会导致错误:“bash: /root/.bashrc: Permission denied”?

  • 3

为什么chroot操作会报错:“ bash: /root/.bashrc: Permission denied”?

我一直chroot出于学习目的进行测试,并且在执行时遇到了以下错误/bin/bash:

nlykkei@debian:~$ id
uid=1000(nlykkei) gid=1000(nlykkei) groups=1000(nlykkei),27(sudo)
nlykkei@debian:~$ sudo chroot --userspec nlykkei:root --groups sudo / /bin/bash
bash: /root/.bashrc: Permission denied
nlykkei@debian:/$ id
uid=1000(nlykkei) gid=0(root) groups=0(root),27(sudo)

似乎/bin/bash是在尝试访问 root.bashrc而不是nlykkei's?

此外,我不能通过创建(复制)来NEWROOT制作~和执行:/bin/bash~/bin/bash

nlykkei@debian:~$ ls -la ~/bin/bash
-rwxr-xr-x 1 nlykkei nlykkei 1168776 Sep 23 10:49 /home/nlykkei/bin/bash
nlykkei@debian:~$ sudo chroot --userspec nlykkei:root --groups sudo /home/nlykkei/ /bin/bash
chroot: failed to run command ‘/bin/bash’: No such file or directory

有什么办法可以解决这些问题?

nlykkei@debian:~$ uname -a
Linux debian 4.19.0-5-amd64 #1 SMP Debian 4.19.37-5 (2019-06-19) x86_64 GNU/Linux
bash
  • 1 个回答
  • 817 Views
Martin Hope
Shuzheng
Asked: 2019-09-07 03:43:12 +0800 CST

动态链接器是由操作系统自动调用还是由 ELF 文件中嵌入的代码自动调用?

  • 4

我不确定,动态链接器/usr/bin/ld是否由操作系统自动调用,在加载 ELF 文件时,还是由嵌入在 ELF 文件中的代码调用?

当我用于r2调试 ELF 文件时,它会在要执行的第一条指令处停止,这应该是动态链接器代码,但我不知道这段代码是否是 ELF 文件的一部分。

linux
  • 1 个回答
  • 388 Views
Martin Hope
Shuzheng
Asked: 2019-09-01 06:56:59 +0800 CST

`>&` 的两个版本中的哪一个用于 `[n]>&/dev/tcp/localhost/9999`?

  • 0

我不确定是解释/dev/tcp/localhost/9999为整数(文件描述符)还是文件名。

因此,我不确定 Bash 手册的“重定向标准输出和标准错误”(1) 或“复制文件描述符”(2) 部分是否适用于上述重定向。

无论是否指定,重定向都有效n,但 (1) 不带n参数,暗示 (1) 未使用?

此外,如果/dev/tcp/localhost/9999被认为是文件名(不是整数),为什么<&1以下命令中的 起作用?:

/bin/bash >&/dev/tcp/localhost/9999 <&1

在这种情况下,1(stdout)不是为输入打开的文件描述符(2)失败?

linux bash
  • 1 个回答
  • 230 Views
Martin Hope
Shuzheng
Asked: 2019-08-31 03:27:13 +0800 CST

在 /etc/systemd/system 中创建为符号链接的全局可写 systemd .service 文件是否会造成安全威胁?

  • 0

作为符号链接创建的全球可写 systemd.service文件是否会/etc/systemd/system带来安全威胁?

是否有可能以某种方式修改指向.service系统上任意文件的链接,并使 systemd 以 root 身份执行这些文件?

该/etc/systemd/system目录的权限如下:

drwxr-xr-x. 11 root root 4096 Aug 30 12:57 /etc/systemd/system/

这个目录中的世界可写链接是:

1050594    0 lrwxrwxrwx   1 root     root            9 Apr  9 11:53 /etc/systemd/system/ctrl-alt-del.target -> /dev/null
1050595    0 lrwxrwxrwx   1 root     root            9 Apr  9 11:54 /etc/systemd/system/sensu-server.service -> /dev/null
1052003    0 lrwxrwxrwx   1 root     root            9 Apr  9 11:54 /etc/systemd/system/sensu-api.service -> /dev/null
1052037    0 lrwxrwxrwx   1 root     root            9 Apr  9 11:55 /etc/systemd/system/dataeng.service -> /dev/null
linux systemd
  • 1 个回答
  • 396 Views
Martin Hope
Shuzheng
Asked: 2019-08-28 23:34:19 +0800 CST

如何在 UNIX 变体(例如 macOS)上使用 sysctl 来读取通常在 Linux 上的 /proc/self 中找到的信息?

  • 2

我已经使用/proc/self了很长时间来阅读与流程相关的信息,例如/proc/self/maps等。

但是,在某些 UNIX 变体上,例如 macOS,procfs文件系统没有实现;但正如此链接所述,应该可以使用sysctl.

从 中读取输出sysctl -a,我发现信息与任何特定进程没有直接关联,而是与系统或内核有关。

那么,我如何使用macOS 等 UNIX 变体sysctl来读取通常存在于 Linux 发行版中的信息?/proc/self

我想例如/proc/self/maps上 macOS。

linux kernel
  • 1 个回答
  • 724 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve