Quantcast
Viewing latest article 4
Browse Latest Browse All 12

Command Line | Change The Owner Of Files And Folders | chown

chown is a Unix/Linux command for changing files and folders ownership.chown become really handy if you want to change the owner for many files or folders using the command line.

As long as you have multiple user accounts available in your system along with your root account, you can the ownership of files and folders between user account, in case you want to make a certain user and group has the privileges of read, write or both in this file or folder.

Check the earlier post for changing files and folders permissions using the command line chmod Here.

Before we go any further make sure exactly which are the folders and files you are going to change the ownership for. because it might effect your currently running system.

[How To]: Check the current files and folders permissions and ownership

There are many different types of listing files and folders can help you to check many information about your files and folder you are currently navigating, such as modified date/time, file size, current owner, associated group, and more.

In this case we will use this command

ls -l

Image may be NSFW.
Clik here to view.

Image may be NSFW.
Clik here to view.

[How To]: change The File or The Folder ownership

In the first screenshot we see many files and folders listed with owner name called “linuxnov”, so here how we are going to change “install.php” file to root owner for example

chown command require root user privileges ” su, sudo “
sudo chown root install.php

Now run list command again for viewing your progress.

[How To]: change The File or The Folder ownership and groups

We will use the same command we used earlier for in step 2 and will add a colon followed by the group name.

sudo chown root:root install.php

Make sure you use an exist user account and group name

[How To]: change ownership for a folder and all sub directories and files beneath it

sudo chown -R root modules

So this will change all files and folder beneath folder called modules to the ownership called root.

That’s it for now.


Viewing latest article 4
Browse Latest Browse All 12

Trending Articles