Results 1 to 6 of 6

Thread: simple ownership script

  1. #1
    Join Date
    Jan 2008
    Location
    Cambridge MA
    Beans
    1,163
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question simple ownership script

    I'm planning on changing the UID of my username for a variety of reasons. When I chance the UID of my username in the /etc/passwd file I also have to update all my files to reflect the proper ownership.

    I'm guessing that the easiest thing will be to write a script that will scan an entire file system and change the owndership ID from one UID to another that I can specify.

    Does anybody know how to write a script like this?
    Allons-y Alonzo! - The Dr.
    Is that what Time Lords do? Lop a bit off, and grow another one. You're like worms! - Donna Noble
    The world is a mess... and I just need to... Rule it. - Dr. Horrible

  2. #2
    Join Date
    Jul 2008
    Location
    Alabama, USA
    Beans
    906
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: simple ownership script

    Code:
    sudo chown -R username /home/username
    That will change all files in your home directory to your ownership.

  3. #3
    Join Date
    Jan 2008
    Location
    Cambridge MA
    Beans
    1,163
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: simple ownership script

    thanks...

    What I was looking for was this:
    Code:
    sudo chown 1050.1050 `find -uid 1000`
    Allons-y Alonzo! - The Dr.
    Is that what Time Lords do? Lop a bit off, and grow another one. You're like worms! - Donna Noble
    The world is a mess... and I just need to... Rule it. - Dr. Horrible

  4. #4
    Join Date
    Jul 2009
    Location
    London
    Beans
    1,480
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: simple ownership script

    sudo chown 1050.1050 `find -uid 1000`
    thats probably not going to work so well for files with spaces. and you may run into issues with the length of the command itself exceeding the max # of characters (depending on how many files the find command expands to)

    so maybe something like this instead:
    Code:
     
    sudo find somedir -uid 1000 -exec chown 1050.1050 {} \;
    though personally I would agree with undecim's approach of chown'ing your home directory ... since all files there should be owned by you and there shouldn't be too many other places in a typical linux filesystem that have files owned by the user (shared data folders aside perhaps)

  5. #5
    Join Date
    Nov 2006
    Location
    UK, London. Wapping.
    Beans
    769
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: simple ownership script

    Quote Originally Posted by undecim View Post
    Code:
    sudo chown -R username /home/username
    That will change all files in your home directory to your ownership.
    I'd add the group to that as well.

    Code:
    sudo chown -R username:username /home/username
    The Other Ubuntu Search Engine touse
    Before following advice look at this.

  6. #6
    Join Date
    Jan 2008
    Location
    Cambridge MA
    Beans
    1,163
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: simple ownership script

    it seems as though the usermod command is what I want:
    Code:
    sudo usermod -u <new uid>
    Allons-y Alonzo! - The Dr.
    Is that what Time Lords do? Lop a bit off, and grow another one. You're like worms! - Donna Noble
    The world is a mess... and I just need to... Rule it. - Dr. Horrible

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •