31

I couldn't log in to my "admin" account and Alt+Ctrl+F1 showed all my files were owned by my "standard" user. Odd.

So I carefully changed to /home/admin and did a

sudo chown -R admin:admin *

(and .* too).

Great.

Then I couldn't log in as my "standard" user and it turns out that all the files in /home/standard were now owned by "admin".

Pretty humorous. Why is this happening?

sudo chown -R standard:standard /home/standard/*

did the same thing, changed /home/admin as well as /home/standard.

I'm more confused than usual because I tried to upgrade to 15.04 and that pretty much wrecked my computer so I'm putting things back with 14.04, please be patient with me.

1
  • Perhaps one is a symbolic link to the other? what does ls -l /home say? Jun 2, 2015 at 22:23

2 Answers 2

41

This issue is caused because you have run:

sudo chown -R admin:admin .*

We know that . indicates the current directory and .. indicates the parent directory. When you run the command with .*, it simply means that match any hidden file in the current directory (stating with .), the current directory itself (.), the parent directory (..). Simply put anything after . (* means 0 or more characters). As a result the parent directory along with all of it child directories get chown-ed to admin:admin.

Look at this test:

test$ ls -al
drwxrwxr-x 4 foo foo 4096 Jun  3 07:15 .
drwxrwxr-x 4 foo foo 4096 Jun  2 18:06 ..
drwxrwxr-x 2 foo foo 4096 Jun  3 07:15 egg
drwxrwxr-x 2 foo foo 4096 Jun  3 07:12 spam

$ sudo chown -R bar:bar spam/.*

test$ ls -al
drwxrwxr-x 4 bar  bar  4096 Jun  3 07:15 .
drwxrwxr-x 4 foo  foo  4096 Jun  2 18:06 ..
drwxrwxr-x 2 bar  bar  4096 Jun  3 07:15 egg
drwxrwxr-x 2 bar  bar  4096 Jun  3 07:12 spam

To revert back you need to chown the affected directories again.

I am not really sure what your plan was, but here are some ideas:

  • To chown any directory recursively (including hidden files):

    sudo chown -R foo:foo /spam/egg/
    
  • To chown only the files (including hidden files) inside that directory (not the directory itself):

    (shopt -s dotglob && sudo chown -R foo:foo egg/*)
    
  • To chown only the non-hidden files (without the directory itself):

    sudo chown -R foo:foo egg/*
    
2
  • Thank you, I get it now... duh ;P Still don't know why the owner changed in the first place unless it was somehow related to Grub giving me an error and crashing the 14.04 install program on me. My standard user was the the first one I created and I later demoted that one and created a new one.
    – DavidP
    Jun 3, 2015 at 17:51
  • @DavidP I am not clear what you are getting at..
    – heemayl
    Jun 4, 2015 at 17:13
3

I think it's the ".*" parameter for files; that matches everything starting with ".", including the "." and the ".." files. The ".." is the parent directory, which includes everything under it.

The best way is to back up one folder, and specify the actual folder you want to change (/home/admin).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .