grep with Regex无法使用非root用户工作

发布于 2025-02-03 02:35:43 字数 1019 浏览 4 评论 0原文

我的命令是./ test。我想获得过程的基础。

我的代码:

Distro: Ubuntu 20.04(grep v3.4)

# run command by test user
test@host:~$ ps -ef | grep tes[t]
test .....    ./test
test .....    grep --color=auto test
       grep with regex not working.

# run command by root user
root@host:~# ps -ef | grep tes[t]
root .....    ./test
    It's Working.

我发现运行PS -EF | grep tes [t] test用户(其他非根本用户也有相同的问题),grep with Regex无法正常工作。
我发现Root用户一直在工作。

PS -EF | grep tes [t]

发行版它正在工作?
Ubuntu 20.04非root用户❎ubuntu
20.04 root用户✅ubuntu
22.04非root用户✅ubuntu
22.04 root用户

为什么该命令在ubuntu 20.04上不适合与非root用户使用?

PS:我知道PS -EF | grep“ tes [t]”(已引用了正则字符串)是alwasy的工作。

My command is ./test. I want to get the pid of process.

my code:

Distro: Ubuntu 20.04(grep v3.4)

# run command by test user
test@host:~$ ps -ef | grep tes[t]
test .....    ./test
test .....    grep --color=auto test
       grep with regex not working.

# run command by root user
root@host:~# ps -ef | grep tes[t]
root .....    ./test
    It's Working.

I found that run ps -ef | grep tes[t] by test user(other non-root user also has the same problem), grep with regex not working.
I found that root user is alway working.

ps -ef | grep tes[t]

DistroIt's working?
Ubuntu 20.04 non-root user
Ubuntu 20.04 root user
Ubuntu 22.04 non-root user
Ubuntu 22.04 root user

Why the command is not working on Ubuntu 20.04 with non-root user?

PS: I know ps -ef | grep "tes[t]" (regex string has been quoted) is alwasy working.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文