Skip to main content

SSH: Finding users home directories.

Comments

3 comments

  • sparek-3
    I really have reservations about what you are doing and how you are doing it. Blindly changing the ownership of files and directory probably isn't a good idea. But to answer your specific question. To get the home directory of a specific user: [font="courier new">homedir=$(getent passwd ${user} | cut -d : -f 6) Then replace instances of [font="courier new">/home/$user with [font="courier new">${homedir}
    0
  • fokakmeny
    I really have reservations about what you are doing and how you are doing it. Blindly changing the ownership of files and directory probably isn't a good idea. But to answer your specific question. To get the home directory of a specific user: homedir=$(getent passwd ${user} | cut -d : -f 6) Then replace instances of /home/$user with ${homedir}

    Works like Charm. Thank you very much. I really appreciate your concern but I'm not changing ownership of all files. I'm just changing ownership for files inside public_html directory which are owned by this user by default. Also since I'm the coder for these 89 websites, I understand the risks. Greetings
    0
  • cPanelLauren
    Thanks for the input on that @sparek-3 - I do agree that blindly changing ownership of files and directories is not recommended practice. @fokakmeny glad to see you were able to get a resolution.
    0

Please sign in to leave a comment.