1

I read a tutorial and was instructed to do chown root:root /home/mynewuser as part of the process to get my ssh key working with a new user i created "kevind", however it broke the path.

What does this do?

How can I reset it back to default? What ever the default would be, /, ~ or something?

Tutorial came from this answer comment.

3

In general: Do not execute commands from the web if you do not know exactly what they do.

Specially by root !!.

The command chown root:root /home/mynewuser is:

changing the ownership to user:group of /home/mynewuser.

However, the first comment from your linked page adds an -R (keep reading).

Assuming the user kevind (using the specific name you provided) has a main group called kevind also created already (you can create it if needed) the command to revert the effect is:

chown kevind:kevind /home/kevind

Which must be executed as/by root to revert the ownership of root to the user kevind.

A more extensive change to ensure that kevind doesn't have some file owned by root inside his directories (security reasons) is:

chown -R kevind:kevind /home/kevind

That will Recurse inside all directories and subdirectories of the given top directory. That is a safe command, there is no real reason for a user to have a file (or directory) owned by root inside his home directory.

1

The command chown root:root changes the user and group of the specified file or directory to user root and group root. I don't know why that answer recommends setting the chowning the directory to root:root.

To partially revert the change, use the command

chown mynewuser /home/mynewuser

This will at least set the user to mynewuser. To find the correct group, you can use either getent or grep the /etc/passwd file for the user, if your system doesn't have getent.

getent passwd mynewuser

grep ^mynewuser: /etc/passwd

You will get a line similar to this:

mynewuser:x:<user>:<group>:...

To include the correct group, use this command, where <group> is the number from the previous line:

chown mynewuser:<group> /home/mynewuser
1

Since the recursive option -R wasn't used, simply using the same command with the mynewuser user and primary group instead of root/root will do it. Assuming like most modern distros whatever you are using puts the new user in its own group with the same name

chown mynewuser.mynewuser /home/mynewuser

as root (or via sudo) will un-do that.

Open a new question with your ssh key issue ...

  • thank you for your response, I was instructed to use chown -R mynewuser:mynewuser /home/mynewuser/ in the line above, what are the reprocussions of this? – Kevin Danikowski Dec 1 '18 at 19:46
  • 1
    @KevinDanikowski the -R makes it recursive - it will operate on that directory, and any file/directory underneath. Since it is the home directory for that user, that is probably appropriate. However, I wasn't sure of your end goal, and so focused on simply reversing the command that you posted in your question. – ivanivan Dec 1 '18 at 20:37

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.