I am doing an online course and the current exercise sees me learning more about sudo. I had to log in as another user and run a command to acccess a password.
In my sudo exercise I have finally got myself logged in as the pseudo user with the discovered password from the first part of the question. Now I have to access a token in the file /root/token.txt. Whilst logged in as the user pseudo I can see from sudo -l the following:
user pseudo may run the following commands on sudo
(ALL) NOPASSWD: ALL
if I cd to the / directory and run ls -la I get
drwx------ 2 root root 4096 Jun 18 1521 root
From the above I deduce only the owner has rwx permissions and that the owner is root. What I am struggling with is how do I access the token file when it would appear to me that I need root access, HELP please?
2 Answers
Since user pseudo may run ALL commands, you should be able to access the file regardless of the directory's owner given that you are already logged in as pseudo e.g.
sudo cat /root/token.txt
Consider sudo as a bash command with options: -u for user, -g for group, where the "default" group is 0, and uid=root. You can now make a special group, "root" - as here. I prefer to call it "admin" or "Administrators" and both "uid" and "gid" must match.