-3

I have logged in as "userc". I need access to all the files that "usera" has. I have edited the following file,

vi /etc/group

usera:x:1000:userb,userc

But this does not seem to work. I am still getting "permission denied" error. If I su to usera then I am able to access those files.

What is the best way to have equivalent access to "root" or "usera"?

Update: I have tried the options suggested in the answer but I am still getting the following:

[root@app company]# cd /opt/company/
[root@app company]# chmod 777 emboss/
[root@app company]# su shantanu
[shantanu@app company]$ whoami
shantanu
[shantanu@app company]$ echo "test" > /opt/company/emboss/todel.txt
bash: /opt/company/emboss/todel.txt: Permission denied
[shantanu@app company]$ sudo echo "test" > /opt/company/emboss/todel.txt
bash: /opt/company/emboss/todel.txt: Permission denied
[shantanu@app company]$ sudo -u usera echo "test" > /opt/company/emboss/todel.txt
bash: /opt/company/emboss/todel.txt: Permission denied
shantanuo
  • 3,579
  • 8
  • 49
  • 66

2 Answers2

2

The files are likely set with no group access (either for the files or the directory) or belong to another group altogether. What are the permissions for the relevant files/directories? (ls -l).

Sven
  • 98,649
  • 14
  • 180
  • 226
2

Answer to What is the best way to have equivalent access to "root" or "usera"?

By default you can use sudo command to execute command as root.

Something like following.

edit /etc/sudoers file and add following line

userc ALL=(usera) NOPASSWD:ALL ## remove NOPASSWD: if you want to enable user authentication

Then user userc should be able to use sudo to run things as user usera with the -u option without entering usera's password.

now sudo allows userc to execute command as usera. The real and effective uid and gid are set to match those of the target user(usera) as specified in the passwd.

sudo -u usera command
Sachin Divekar
  • 2,525
  • 2
  • 21
  • 23