Home / VPS & Dedicated / Changing file ownership in Linux

Changing file ownership in Linux

hand holding car keys
There are many situations when you may need to change the ownership of files, especially if you are operating a virtual private server or dedicated server. For example, you may install something for a website as root but then need to set ownership of the file to the local user. Linux has a convenient command called “chown” that does exactly that. The word “chown” is short for “change the owner”.

Let’s suppose that you have a file called “testfile” owned by root. You want to change ownership to user1. Simply enter this command:

chown user1:users testfile

In this case, “user1” is the user’s name and “users” is its user group.

If you want to change the ownership of all the files in a directory, you would add the “-R” tag to make the operation recursive.

chown -R user1:users test-directory

For more information about chown, enter this command: man chown.

Photo Source: SXC

Check Also

servers

Importance of web hosting to business

The world of business is very ruthless and unfair in some cases. It is a …

Powered by Namesco
© Copyright InternetBlog.Org.Uk 2024, All Rights Reserved