尝试将用户添加到 systemd-journal 组时存在用户

shi*_*ish 6 users permissions debian group mate-desktop

我一直想通过运行/使用来阅读 systemd-journal journalctl -b。现在,如果我以用户身份运行它,我会得到以下信息:-

$ journalctl -b
Hint: You are currently not seeing messages from other users and the system
      Users in the 'systemd-journal' group can see all messages. Pass -q to
      turn off this notice.
No journal files were opened due to insufficient permissions.
Run Code Online (Sandbox Code Playgroud)

在此之后,我在 /etc/group 中运行了一个 grep 以查看是否存在这样的组。

$ sudo grep systemd-journal /etc/group
systemd-journal:x:102:
systemd-journal-remote:x:128:
Run Code Online (Sandbox Code Playgroud)

然后我尝试将用户添加到该组:-

$ sudo useradd -G systemd-journal shirish
useradd: user 'shirish' already exists
Run Code Online (Sandbox Code Playgroud)

你可以看看它说的是什么。

我使用 id 命令来查找 shirish 属于哪些组

$ id shirish
uid=1000(shirish) gid=1000(shirish) groups=1000(shirish),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),108(netdev),110(lpadmin),113(scanner),119(bluetooth),131(kvm),132(libvirt)
Run Code Online (Sandbox Code Playgroud)

可以看出,我并不希望成为 systemd-journal 的成员。

Tom*_*unt 9

您不习惯useradd将用户添加到组中。您用于useradd创建用户,因此出现错误消息。尝试:

# usermod -a -G systemd-journal shirish
Run Code Online (Sandbox Code Playgroud)

或者

# gpasswd -a shirish systemd-journal
Run Code Online (Sandbox Code Playgroud)

无论哪种情况,都需要重新登录才能生效。在运行的 shell 中执行此操作的一种快速而肮脏的方法是:

$ exec su - shirish
Run Code Online (Sandbox Code Playgroud)