Results 1 to 17 of 17
  1. #1
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,052

    How to change file ownership in SSH?

    I have a few files that have root as owner. I'm having trouble finding the SSH command to change ownership to a specific user. I logged in as root and entered

    chown -R newusername *

    but it doesn't do anything.

    What is the proper command?

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  2. #2
    Join Date
    May 2006
    Posts
    134
    chown to change the username
    chgrp to change the group

    -R makes it recursive

    If you want to change all files and subdirectories in the current folder:

    chown -R username *
    chgrp -R group *

    (group is usually the same as the username)

    Or just to change permissions:

    chmod -R xxx *

  3. #3
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,052
    Perfect, thank you. I had tried chown -R username * , but I was missing chgrp -R group *.

    Thanks again.

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  4. #4
    Join Date
    Nov 2001
    Location
    Vancouver
    Posts
    2,422
    or, use chown to do both

    chown -R ownername:groupname *

    or one at a time

    chown -R ownername *
    chown -R :groupname *


    More importantly:

    man chown
    “Even those who arrange and design shrubberies are under
    considerable economic stress at this period in history.”

  5. #5
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,052
    Quote Originally Posted by mwatkins

    More importantly:

    man chown
    Sorry, I'm confused. What is that command for?

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  6. #6
    Join Date
    Mar 2005
    Location
    Cardboard box
    Posts
    1,027
    man typically displays the manual of what follows.

  7. #7
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,052
    Ah, haha, I see. Good point.

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  8. #8
    Join Date
    Nov 2001
    Location
    Vancouver
    Posts
    2,422
    vito - I included that there not to chide you but to remind you that man is an incredibly useful tool. Before I start googling and long before I ask other people for answers, man is my first stop.

    Can't remember the various options for chmod? man chmod
    Forget string formatting parameters in PHP or Python or C? man sprintf will probably get you there.
    “Even those who arrange and design shrubberies are under
    considerable economic stress at this period in history.”

  9. #9
    Join Date
    Dec 2005
    Posts
    368
    And if you forget the correct man syntax, "man man" will help you out!

    Of course you need to be secure in your manhood before you can type commands such as "man touch" or "man yum".

  10. #10
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,052
    No worries, mwatkins. I didn't take your post to be negative at all. I never knew about that command so that will definitely help in future.

    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  11. #11
    Join Date
    Jan 2002
    Location
    Toronto, Canada
    Posts
    11,052
    Quote Originally Posted by tobiasly
    Of course you need to be secure in your manhood before you can type commands such as "man touch" or "man yum".
    [*...clears voice...burps a couple of times...swears for no reason...OK, I'm ready.../*]



    Vito
    DemoDemo.com - Flash tutorials since 2002
    DemoWolf.com - 5,300+ Flash tutorials for hosting companies, incl. Voice tutorials

  12. #12
    Join Date
    Nov 2001
    Location
    Vancouver
    Posts
    2,422
    vito:

    tobiasly: LOL!
    “Even those who arrange and design shrubberies are under
    considerable economic stress at this period in history.”

  13. #13
    Join Date
    Jun 2006
    Location
    Colorado
    Posts
    55
    Okay, I was doing this earlier...I could change the owner of a directory, but it would not change the owner of the directories' contents.

    I was doing:
    chown username. directory

    To get the directory and its contents, would I just do:
    chown username. directory/*

    or do I go into the directory that I want to change ownership to and just do
    chown username. *
    Last edited by bdmorrison; 06-02-2006 at 05:53 PM.

  14. #14
    Join Date
    Mar 2005
    Location
    Cardboard box
    Posts
    1,027
    So you are trying to issue the command recursively? Try chown --recursive or chown -R, instead of just chown.

  15. #15
    Join Date
    Jun 2006
    Location
    Colorado
    Posts
    55
    so chown -R will change the owner of the directory and its contents?

    Thanks!

  16. #16
    Join Date
    Apr 2005
    Location
    Holland
    Posts
    124
    -R option will change given directory _and_ everything in it!

    Aleks

  17. #17
    Join Date
    Mar 2005
    Location
    Cardboard box
    Posts
    1,027
    Quote Originally Posted by bdmorrison
    so chown -R will change the owner of the directory and its contents?
    Yes.

    You can use chown -Rv (recursive + verbose) to see the files processed. This will help you better understand how it works. Good luck.

Posting Permissions

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