使用管理员权限创建的用户但出现权限被拒绝错误

使用管理员权限创建的用户但出现权限被拒绝错误

我创建了一个具有管理员权限的用户。对于某些主机,Linux 命令可以无缝运行,但对于某些系统,输入命令时会显示权限被拒绝:

praveen.kumar@chn_lab:/home/admin$ free -m |grep Mem |awk '{print $3/$2 * 100.0}',
bash: /usr/bin/awk: Permission denied
praveen.kumar@mum_lab:~$ free -m |grep Mem |awk '{print $3/$2 * 100.0}'
53.9168

工作机权限:

praveen.kumar@mum_lab:~$ cat /etc/passwd
admin:x:1003:1000::/home/admin:/bin/bash
praveen.kumar:x:1004:1000:praveen.kumar:/home/praveen.kumar:/bin/bash

出现错误的机器权限:

praveen.kumar@chn_lab:~$ cat /etc/passwd
admin:x:1002:1000::/home/admin:/bin/bash
praveen.kumar:x:1011:1000::/home/praveen.kumar:/bin/bash

对于与管理员用户相同的用户,如何纠正此权限被拒绝错误?

回复@artur-meinild - 请查看以下输出:

praveen.kumar@chn_lab:~$ pwd
/home/praveen.kumar

praveen.kumar@chn_lab:~$ free -m |grep Mem |awk '{print $3/$2 * 100.0}'
-bash: /usr/bin/awk: Permission denied

praveen.kumar@chn_lab:~$ stat /usr/bin/awk
  File: ‘/usr/bin/awk’ -> ‘/etc/alternatives/awk’
  Size: 21              Blocks: 0          IO Block: 4096   symbolic link
Device: fc00h/64512d    Inode: 13762578    Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-11-15 13:15:01.597965097 +0530
Modify: 2017-06-29 19:02:55.708005841 +0530
Change: 2017-06-29 19:02:55.708005841 +0530
 Birth: -

回复@Artur

praveen.kumar@chn_lab:~$ stat /etc/alternatives/awk
  File: ‘/etc/alternatives/awk’ -> ‘/usr/bin/gawk’
  Size: 13              Blocks: 0          IO Block: 4096   symbolic link
Device: fc00h/64512d    Inode: 62916691    Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-11-15 15:12:01.795430384 +0530
Modify: 2021-01-09 14:56:38.459865499 +0530
Change: 2021-01-09 14:56:38.459865499 +0530
 Birth: -
praveen.kumar@chn_lab:~$

回复用户68186:

praveen.kumar@chn_lab:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04.2 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.2 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

回复@artur

praveen.kumar@chn_lab:~$ stat /usr/bin/gawk
  File: ‘/usr/bin/gawk’
  Size: 441512          Blocks: 864        IO Block: 4096   regular file
Device: fc00h/64512d    Inode: 13767920    Links: 1
Access: (0110/---x--x---)  Uid: (    0/    root)   Gid: ( 1001/versa_priv)
Access: 2022-11-15 10:15:01.635322812 +0530
Modify: 2013-07-03 02:12:04.000000000 +0530
Change: 2022-06-04 10:11:36.905723865 +0530
 Birth: -

答案1

是的,您的/usr/bin/gawk权限无效。

做:

sudo chmod 755 /usr/bin/gawk

然后它就会运行。

相关内容