grep with Regex无法使用非root用户工作
我的命令是./ 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]
Distro | It'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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论