I have created a file named *.txt
in /home
using following command:
sudo nano *.txt
Then I have changed owner of *.txt
to a user
that I've created:
sudo useradd -c "ABC"
sudo chown ABC *.txt
I login to ABC
by typing:
sudo login ABC
I tried to change permission of the file:
sudo chmod 777 *.txt
This is the result:
ABC is not in the sudoers file. This incident will be reported.
Permissions have successfully changed when running chmod
from the original user: batman
.
How can I change the permissions of *.txt
from the new owner?
Best Answer
If you step through your commands and the output these are your problems.
The file
*.txt
is located in batman's home directory.Switch to ABC user:
sudo login ABC
. You just made ABC and it doesn't have a home directory so you got thrown into the root directoryYou try
chmod 777 *.txt
, but you are in the root dir and the file is not there.You exit back into batman and try to chmod the file, but now it belongs to ABC and batman can't change it.
To Solve:
login as batman