# Put a file into users home directory

**URL:** <https://forum.ansible.com/t/put-a-file-into-users-home-directory/12700>\
**Category:** Ansible Project\
**Created:** [April 19, 2013, 4:52pm UTC](https://forum.ansible.com/t/put-a-file-into-users-home-directory/12700 "2013-04-19T16:52:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oscar\_Korz](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@Oscar\_Korz](https://forum.ansible.com/u/Oscar_Korz)\
**Post date:** [April 19, 2013, 4:52pm UTC](https://forum.ansible.com/t/put-a-file-into-users-home-directory/12700/1 "2013-04-19T16:52:56Z")

</div>

I’ve got a very silly question that I haven’t been able to find a simple solution to:

I want to copy a config file into users’ home directories but I don’t know their home directories on the controller (and they may vary from host to host). What’s the best way to look up a user’s home directory on the host? I know that I could capture the output from a shell command, but this feels hacky. I’d prefer a solution that doesn’t get flagged as “changed” every time.

Thanks,  
Oscar.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [April 19, 2013, 5:35pm UTC](https://forum.ansible.com/t/put-a-file-into-users-home-directory/12700/2 "2013-04-19T17:35:25Z")

</div>

You can just use “~/” on the path name for the “dest” file, the homedir will expand on the remote side as you expect.

---

<div class="post-metadata">

**Author:** ![Oscar\_Korz](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@Oscar\_Korz](https://forum.ansible.com/u/Oscar_Korz)\
**Post date:** [April 19, 2013, 5:40pm UTC](https://forum.ansible.com/t/put-a-file-into-users-home-directory/12700/3 "2013-04-19T17:40:40Z")

</div>

Ah, thanks for the quick response.

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [April 19, 2013, 6:17pm UTC](https://forum.ansible.com/t/put-a-file-into-users-home-directory/12700/4 "2013-04-19T18:17:39Z")

</div>

​Be aware that this is the home directory or the user you are logging on to  
the remote host with.​  
If you need to copy to other users home directory, knowing their usernames,  
you can use "~username/".  
You probably will need root permissions to do that, and don't orget to set  
the file's permissions to the target user.

Serge

---

<div class="post-metadata">

**Author:** ![Rohit\_Dubey1](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@Rohit\_Dubey1](https://forum.ansible.com/u/Rohit_Dubey1)\
**Post date:** [November 4, 2015, 1:57pm UTC](https://forum.ansible.com/t/put-a-file-into-users-home-directory/12700/5 "2015-11-04T13:57:06Z")

</div>

Hi :

I am a newbie . Would the user subtitution from vars file also i.e ~{{user}}/ .  
I guess I’ll find out and report back .

Thanks anyways .
