Score:0

user created with admin rights but getting permission denied error

in flag

I have a created user which has admin access. For some hosts the linux commands work seamlessly, but for some systems when the command is entered it shows permission denied:

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

Permissions of working machine:

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

Permissions of machine with error:

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

How to rectify this permission denied error for the user created same as an admin user?

Replying to @artur-meinild - please find the outputs below:

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: -

Replying to @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:~$

replying to user68186:

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/"

replying to @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: -
Score:1
vn flag

Yes, your /usr/bin/gawk has invalid permissions.

Do:

sudo chmod 755 /usr/bin/gawk

Then it will run.

Praveen Kumar avatar
in flag
Thanks! this works in lab, let me validate the same in my production environment and revert back
Artur Meinild avatar
vn flag
Please ask a new question, and provide all relevant details. Thanks.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.