# How to check if the current user has write access to a given path ?

**URL:** <https://forum.ansible.com/t/how-to-check-if-the-current-user-has-write-access-to-a-given-path/22143>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [July 28, 2016, 9:36am UTC](https://forum.ansible.com/t/how-to-check-if-the-current-user-has-write-access-to-a-given-path/22143 "2016-07-28T09:36:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ishan\_jain](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@ishan\_jain](https://forum.ansible.com/u/ishan_jain)\
**Post date:** [July 28, 2016, 9:36am UTC](https://forum.ansible.com/t/how-to-check-if-the-current-user-has-write-access-to-a-given-path/22143/1 "2016-07-28T09:36:56Z")

</div>

I am trying to check via Ansible that whether the user (being used to connect) has write access to a given path - both on **linux hosts and windows hosts**.

I tried looking around but i could not get an easy way to do that. I might be getting wrong paths a lot, so the typical commands with raw module is not a good idea. So what i thought of is to create try and create a file in the path, possibly with the name as current epoch and later remove it.

Anybody have a better idea on how to do this for windows and linux machines ?

---

<div class="post-metadata">

**Author:** ![Alli](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@Alli](https://forum.ansible.com/u/Alli)\
**Post date:** [July 28, 2016, 11:14am UTC](https://forum.ansible.com/t/how-to-check-if-the-current-user-has-write-access-to-a-given-path/22143/2 "2016-07-28T11:14:36Z")

</div>

Would stat achieve this for you?

[http://docs.ansible.com/ansible/stat\_module.html](http://docs.ansible.com/ansible/stat_module.html)

---

<div class="post-metadata">

**Author:** ![ishan\_jain](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@ishan\_jain](https://forum.ansible.com/u/ishan_jain)\
**Post date:** [August 1, 2016, 6:13am UTC](https://forum.ansible.com/t/how-to-check-if-the-current-user-has-write-access-to-a-given-path/22143/3 "2016-08-01T06:13:17Z")

</div>

Directly it didn’t help me. What i did is a 3 step process - create a folder with timestamp in name (for uniqueness), check if it was created and then delete it.
