0

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?

This is inside <code>ABC</code> user

6
  • 1. please copy & paste output instead of screenshots; 2. to use sudo in Ubuntu you need to be in the sudo group (or you need to be in the sudoers file like the error suggests); 3. you're getting "no such file or directory" because you forgot to cd to the right directory – Andrea Corbellini Mar 21 '16 at 17:30
  • What's the right directory? It should be in ABC user, right? – Johny Nassar Mar 21 '16 at 17:34
  • No, you created the files in your home directory, they can't be in ABC's home directory: cd ~batman; chmod 744 *.txt -- but you may get errors depending on the directory permissions – Andrea Corbellini Mar 21 '16 at 17:36
  • I'm new to Ubuntu so I don't get it 100% the group idea. Sorry. – Johny Nassar Mar 21 '16 at 17:38
  • But the ABC user is the new owner of this file. Right? How can I fix it ? – Johny Nassar Mar 21 '16 at 17:39
0

If you step through your commands and the output these are your problems.

The file *.txt is located in batman's home directory.

  1. 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 directory

  2. You try chmod 777 *.txt, but you are in the root dir and the file is not there.

  3. 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

su ABC

cd /home/batman

chown 777 *.txt
1
  • I have some questions: 1. How can I make a home directory for ABC. 2. When I make a chmod, It's obligatory that I must go to the file location? 3.When I tried to chmod in the batman it's successfully completed and there's no problem with that!! Why? Thanks. – Johny Nassar Mar 22 '16 at 6:37
0

All I need to do is to be in the directory which contains the file. Solution:

cd home

chmod 777 *.txt

That's all. But be aware to change the name of the file because the * in *.txt isn't a valid name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.