小编Vla*_*eev的帖子

替换一个正则表达式,然后在所有不匹配的行中替换第二个正则表达式

示例任务:如果一行包含foo,则将其替换为bar,否则附加baz到该行。

sed -e s/foo/bar/ -e s/$/baz/不起作用,因为无论第一个命令是否匹配,都会执行第二个命令。有没有办法告诉sed比赛结束后转到下一行?

sed

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

具有桥接接口的 Linux 网络控制台

我试图netconsole在我的家用 PC上启用,但是在我的桥接 LAN 和 Wi-Fi 上遇到了一些问题。

  1. 如果我不指定接口名称,则会失败,如下所示:

    $ sudo modprobe netconsole netconsole=6666@192.168.0.1/,6666@192.168.0.2/A0:F3:C1:FF:4C:70 
    modprobe: ERROR: could not insert 'netconsole': No such device
    
    Run Code Online (Sandbox Code Playgroud)

    dmesg 输出:

    netpoll: netconsole: local port 6666
    netpoll: netconsole: local IPv4 address 192.168.0.1
    netpoll: netconsole: interface 'eth0'
    netpoll: netconsole: remote port 6666
    netpoll: netconsole: remote IPv4 address 192.168.0.2
    netpoll: netconsole: remote ethernet address a0:f3:c1:ff:4c:70
    netpoll: netconsole: eth0 doesn't exist, aborting
    netconsole: cleaning up
    
    Run Code Online (Sandbox Code Playgroud)

    它尝试查找eth0并失败,很可能是因为 systemd 将其重命名为enp9s0.

  2. 如果我明确指定新接口名称:

    $ sudo modprobe netconsole netconsole=6666@192.168.0.1/enp9s0,6666@192.168.0.2/A0:F3:C1:FF:4C:70
    modprobe: …
    Run Code Online (Sandbox Code Playgroud)

linux networking bridge

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

主拒绝会话请求:权限被拒绝

我正在尝试设置 SSH 多路复用,但我遇到了一个错误,并且在 Google 上有 0 次点击以获得确切的错误消息。

~/.ssh/config用内容创建:

Host *
 ControlPath ~/.ssh/master-%r@%h:%p
Run Code Online (Sandbox Code Playgroud)

然后,我通过运行创建了主连接:

ssh -vMM user@host.example.com
Run Code Online (Sandbox Code Playgroud)

这似乎成功创建了多路复用套接字:

...
Authenticated to host.example.com ([1.2.3.4]:22).
debug1: setting up multiplex master socket
debug1: channel 0: new [/home/user/.ssh/master-user@host.example.com:22]
debug1: channel 1: new [client-session]
debug1: Entering interactive session.
...
Run Code Online (Sandbox Code Playgroud)

然后,我尝试在另一个窗口中通过 ssh 运行命令:

ssh -v user@host.example.com ls
Run Code Online (Sandbox Code Playgroud)

但是,这似乎无法使用多路复用套接字:

OpenSSH_7.5p1, OpenSSL 1.1.0f  25 May 2017
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
Master refused session …
Run Code Online (Sandbox Code Playgroud)

openssh

4
推荐指数
1
解决办法
937
查看次数

为什么 macOS 上的 screen 不接收我的 ~/.terminfo?

我想让我的终端 (rxvt-unicode) 的Terminfo正常工作,以便当我从 Linux ssh 到 macOS 时,Home/End 和其他键可以正常工作。

通常,要使用 Linux 远程主机完成此操作,我会使用如下脚本:

ssh "$1" 'mkdir -p ~/.terminfo/r'
for f in /usr/share/terminfo/r/rxvt-unicode{,-256color}
do
    scp "$f" "$1":.terminfo/r/
done
Run Code Online (Sandbox Code Playgroud)

但是,这不适用于 macOS。

当我运行时screen,首先我收到“TERM 太长 - 抱歉。”。

将其更新到 brew 版本 (4.06.02) 后,我现在收到“无法找到 'rxvt-unicode-256color' 的 terminfo 条目。”

TERM正确设置为rxvt-unicode-256color,并且~/.terminfo/r/rxvt-unicode-256color存在。

跑步screenTERMINFO=$HOME/.terminfo/也没有效果。

osx gnu-screen terminfo

4
推荐指数
2
解决办法
2746
查看次数

标签 统计

bridge ×1

gnu-screen ×1

linux ×1

networking ×1

openssh ×1

osx ×1

sed ×1

terminfo ×1