小编Mar*_*ler的帖子

如何禁用(然后重新启用)我的一个 NVIDIA GPU?

我正在开发一个具有多个 NVIDIA GPU 的系统。我想禁用/使我的一个 GPU 消失,而不是其他 GPU;无需重新启动;以便我稍后可以重新启用它。

这可能吗?

笔记:

  • 假设我有root权限(尽管对于拥有设备文件权限的用户来说,非root解决方案更好)。
  • 如果重要的话,发行版是 SLES 12 或 SLES 15,并且 - 不要问我为什么:-(

linux nvidia sles gpu

14
推荐指数
1
解决办法
2万
查看次数

为什么“cpulimit”不能限制chrome浏览器?

由于 CPU 使用率高,我想限制 Chromium 网络浏览器cpulimit并使用终端运行:

cpulimit -l 30 -- chromium --incognito
Run Code Online (Sandbox Code Playgroud)

但它并没有像预期的那样限制 CPU 使用率(即最大为 30%)。它再次使用 100%。为什么?我究竟做错了什么?

chrome cpulimit

13
推荐指数
2
解决办法
1762
查看次数

Linux 命名管道:并不像想象的那样先进先出

简而言之:

\n
mkfifo fifo; (echo a > fifo) &; (echo b > fifo) &; cat fifo\n
Run Code Online (Sandbox Code Playgroud)\n

我所期望的:

\n
a\nb\n
Run Code Online (Sandbox Code Playgroud)\n

因为第一个echo \xe2\x80\xa6 > fifo应该是第一个打开该文件的进程,所以我希望该进程是第一个写入该文件的进程(首先打开它并解锁)。

\n

我得到什么:

\n
b\na\n
Run Code Online (Sandbox Code Playgroud)\n

令我惊讶的是,当打开两个单独的终端在绝对独立的进程中进行写入时,也会发生这种行为。

\n

我是否误解了命名管道的先进先出语义?

\n

斯蒂芬建议添加延迟:

\n
mkfifo fifo; (echo a > fifo) &; (echo b > fifo) &; cat fifo\n
Run Code Online (Sandbox Code Playgroud)\n

现在,这 100% 正确 ( delay = 0.1, N = 100)。

\n

尽管如此,mkfifo fifo; (echo a > fifo) &; sleep 0.1 ; (echo b > fifo) …

linux fifo

11
推荐指数
2
解决办法
4637
查看次数

如何在 Amazon Linux 2023 上通过 snap 安装 certbot

I am following this guide on how to Configure SSL/TLS on Amazon Linux 2023. It recommends to obtain a CA-signed certificate using Certbot. And to get Certbot, it's recommended to install Snap.

I have tried several things, not able to install any of prerequisites:

sudo yum install snapd
    Error: Unable to find a match: snapd

sudo amazon-linux-extras install epel
    sudo: amazon-linux-extras: command not found

sudo yum install -y amazon-linux-extras
    Error: Unable to find a match: amazon-linux-extras
Run Code Online (Sandbox Code Playgroud)

certbot amazon-linux snap

10
推荐指数
1
解决办法
4883
查看次数

为什么Wine可以将Windows系统调用转换为Linux系统调用?

只要体系结构相同,Windows .exe 文件可以在 Linux 系统上运行也就不足为奇了(如果它正确加载到 RAM 上)。但Linux和Windows的系统调用完全不同。因此,当 .exe 文件在 Linux 上调用系统调用时,结果将不是我们所期望的。

我认为 Wine 将 Windows 系统调用转换为 Linux 系统调用,但我无法想象如何转换。也许系统调用是通过int、syscall、systenter等实现的。Wine是否通过某种方式直接hook这样的操作?

windows system-calls wine

9
推荐指数
1
解决办法
4039
查看次数

为什么在这个脚本中等待所有子shell之后都没有执行?

在此脚本中,将拉取所有 git 存储库:

#!/bin/bash

find / -type d -name .git 2>/dev/null | 
while read gitFolder; do
    if [[ $gitFolder == *"/Temp/"* ]]; then
        continue;
    fi
    if [[ $gitFolder == *"/Trash/"* ]]; then
        continue;
    fi
    if [[ $gitFolder == *"/opt/"* ]]; then
        continue;
    fi
    parent=$(dirname $gitFolder);
    echo "";
    echo $parent;
    (git -C $parent pull && echo "Got $parent") &
done 
wait
echo "Got all"
Run Code Online (Sandbox Code Playgroud)

wait等待所有git pull子 shell。

为什么会这样?我该如何解决?

subshell wait

7
推荐指数
1
解决办法
659
查看次数

我观察到使用 `dd if=filein of=fileout` 会导致文件系统碎片,我需要更改什么?

有一个很好的问题,遗憾的是在我写一个相当广泛的答案时被删除了:(

\n

不想让这种努力白费,让我从问题文本和评论中解释一下这个问题:

\n
\n

我观察到使用dd覆盖文件确实会增加碎片。我正在寻找一种dd不会导致碎片化的替代方案。

\n

作为碎片如何发生的示例:想象一个占据整个文件系统的文件。开始覆盖它,您将立即看到该分区如何变得完全“空闲”,同时您将能够向其中写入另一个文件。块是动态分配的,并且当文件被覆盖时,零保证旧块将被重用。

\n

我在多个文件系统(ext2、3 和 4、XFS、以及 FAT32 和 NTFS)和多个操作系统(win95 到现代 Fedora)\xc2\xb2 上观察到这种行为。

\n

我确信这与文件系统和操作系统无关。

\n

我的主文件系统是 Bog 标准 ext4。FedoraROOT:103874/1310720 个文件(0.2% 不连续),1754833/5242880 个块。最小的整体碎片。

\n
\n
\n

请注意,自己无法观察到这一点,我相信这些碎片声明的原始提问者!

\n

filesystems dd defragmentation

6
推荐指数
1
解决办法
352
查看次数

Ansible:在 sshd_config 中添加用户

一名新员工加入,我需要允许他访问测试服务器。通常我使用模板并根据环境类型将此模板上传到服务器上。但这次我想使用不同的方法:我只想在且仅当用户不可用时才在sshd_config末尾添加此新用户。AllowUsers

尝试过lineinfile模块但到目前为止没有成功。

sshd ansible

6
推荐指数
1
解决办法
1636
查看次数

笔记本电脑盖关闭时等待然后休眠

我对“暂停然后休眠”作为盖子关闭操作有疑问。

因此,我希望系统关闭并锁定屏幕,并在盖子关闭后等待 10 分钟(但不暂停),而不是暂停,然后(如果盖子保持关闭状态)进入休眠状态。

可以使用 systemd 来做到这一点吗?

hibernate systemd

5
推荐指数
0
解决办法
135
查看次数

如何使用 Linux 命令模拟 #include <myFile.txt>

因此,我尝试从包含其他文件的源文件创建输出文件。

(我的用例实际上是 Kubernetes/OpenShift 的 YAML,但这些 .txt 文件显示了目标。)

例如:

% cat source.txt
This is the source files it will include two other files.
The first will be here:
#INCLUDE ./first-included-file.txt
And the second file will be inserted here:
#INCLUDE ./second-included-file.txt
And this is the end of source.txt
Run Code Online (Sandbox Code Playgroud)

如果包含的文件是:

% cat first-included-file.txt
This is FIRST
End of FIRST

% cat second-included-file.txt
This is SECOND
End of SECOND
Run Code Online (Sandbox Code Playgroud)

那么输出将是:

This is the source files it will include two other files.
The first will …
Run Code Online (Sandbox Code Playgroud)

text-processing

5
推荐指数
1
解决办法
151
查看次数