DEV Community

Cover image for How to change ownership of a file in Nodejs?
Omar Dulaimi
Omar Dulaimi

Posted on

4 1

How to change ownership of a file in Nodejs?

As for our last permissions and access related methods, today we talk about the 𝗰𝗵𝗼𝘄𝗻 method.

It lets you change the ownership of a file. Just like you're used to on your terminal:

𝗰𝗵𝗼𝘄𝗻 <𝗨𝘀𝗲𝗿><:><𝗚𝗿𝗼𝘂𝗽> <𝗙𝗶𝗹𝗲>

𝗡𝗼𝗱𝗲𝗷𝘀 provides support for it natively; so you won't have to spawn a process to access this API.

You can check the updated values with this basic list command:

𝗹𝘀 -𝗹 <𝗙𝗜𝗟𝗘>

change ownership


Did you learn something new today?

Like and share this post, and follow me for more!

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

Thanks for reading! If you found this post useful, please consider leaving a ❤️ or a kind comment.

Absolutely!