Predictive Hacks

How to Change File and Directory Ownership in Unix

The command has the following structure:

For files:

chown user:group filename

For directories:

chown user:group directoryname

For directories, we change the ownership of the directory BUT not for the files inside it. If we want to change the inside files, we should use the -R:

chown -R user:group directoryname

Note, that it can work by specifying only the user or only the group:

Only the user:

chown user filename

Only the group:

chown :group filename

Finally, bear in mind that it is possible not to have the permissions to change ownership and you may need to run the command with sudo:

chown sudo user:group filename

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Python

Image Captioning with HuggingFace

Image captioning with AI is a fascinating application of artificial intelligence (AI) that involves generating textual descriptions for images automatically.

Python

Intro to Chatbots with HuggingFace

In this tutorial, we will show you how to use the Transformers library from HuggingFace to build chatbot pipelines. Let’s