# Understanding IPFS directories

**URL:** <https://discuss.ipfs.tech/t/understanding-ipfs-directories/2219>\
**Category:** Help\
**Created:** [March 2, 2018, 9:51pm UTC](https://discuss.ipfs.tech/t/understanding-ipfs-directories/2219 "2018-03-02T21:51:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MirceaKitsune](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/mirceakitsune/32/1610_2.png) [@MirceaKitsune](https://discuss.ipfs.tech/u/MirceaKitsune)\
**Post date:** [March 2, 2018, 9:51pm UTC](https://discuss.ipfs.tech/t/understanding-ipfs-directories/2219/1 "2018-03-02T21:51:26Z")

</div>

I know that IPFS supports directories additionally to just files. But I don’t quite understand how they work, and more importantly what they can do.

I’m hoping directories might be able to provide a workaround to needing IPNS for every aspect of a dynamic website, as is implied by file immutability. If files could be added to directories in which they may be referenced by a file name, this would make a lot of additional abilities possible.

First of all I wanted to know how you can add a file to a directory or remove it from one. Is there a command of the form “ipfs add my\_file.jpg ipns\_name.com/my\_directory”?

If that’s possible: Can a file be referenced by its file name rather than its hash from a directory?

Lastly: Can directories be given specific rights protected by a key or password? For instance: Only the owner can delete files from the directory, but others can add new files or read existing files.

---

<div class="post-metadata">

**Author:** ![stebalien](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/stebalien/32/156_2.png) [@stebalien](https://discuss.ipfs.tech/u/stebalien)\
**Post date:** [March 3, 2018, 2:59am UTC](https://discuss.ipfs.tech/t/understanding-ipfs-directories/2219/2 "2018-03-03T02:59:19Z")

</div>

Directories are also immutable. Think of them as files that point to other files.

Unfortunately, we don’t have any built-in support for authentication or encryption. You can layer that on-top of IPFS but you’ll have to do that yourself.

If you’re looking for a way to work with files (mutably) in IPFS, take a look at the `ipfs files` command. That gives you a local mutable filesystem stored in ipfs. You can get the _current_ IPFS hash of any file in that filesystem by running `ipfs files stat --hash /path/to/my/file`.

---

<div class="post-metadata">

**Author:** ![MirceaKitsune](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/mirceakitsune/32/1610_2.png) [@MirceaKitsune](https://discuss.ipfs.tech/u/MirceaKitsune)\
**Post date:** [March 3, 2018, 2:22pm UTC](https://discuss.ipfs.tech/t/understanding-ipfs-directories/2219/3 "2018-03-03T14:22:14Z")

</div>

Now that is very helpful! I had no idea you can also reference files by a filename in IPFS, I thought the hash is all that is ever available. So if I update a file with the right arguments, can I still keep the file name… meaning the “ipfs files” command will return the hash of the updated file for a given name?

---

<div class="post-metadata">

**Author:** ![stebalien](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/stebalien/32/156_2.png) [@stebalien](https://discuss.ipfs.tech/u/stebalien)\
**Post date:** [March 3, 2018, 5:48pm UTC](https://discuss.ipfs.tech/t/understanding-ipfs-directories/2219/4 "2018-03-03T17:48:15Z")

</div>

> So if I update a file with the right arguments, can I still keep the file name… meaning the “ipfs files” command will return the hash of the updated file for a given name?

Yes. The easiest way is to simply overwrite the file but you can also, e.g., write to it with `ipfs files write ...`. Eventually, we’d like to provide a separate fuse daemon so you can _mount_ this as a virtual filesystem but we don’t have one yet.

---

<div class="post-metadata">

**Author:** ![MirceaKitsune](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/mirceakitsune/32/1610_2.png) [@MirceaKitsune](https://discuss.ipfs.tech/u/MirceaKitsune)\
**Post date:** [March 3, 2018, 8:21pm UTC](https://discuss.ipfs.tech/t/understanding-ipfs-directories/2219/5 "2018-03-03T20:21:13Z")

</div>

Very interesting! Virtual file system would be nice too… in this case the best use would be globally (so you can reference a changing file the same way everywhere).
