How to change ownership of folder Linux

Linux ownership rights to files and folders form the basis of access control to different features of the operating system. What user and group owns the folder determines who can access it, create and delete files and other folders, and so on.

In this small article we will consider how to change the owner of folder in Linux the GUI or using the terminal.

How to change ownership of folder Linux

You can change the owner of the folder using your file Manager, e.g. Nautilus. But for this we need to run file Manager as root. Open the terminal with shortcut keys Ctrl+Alt+T and run the command:

sudo nautilus

Then browse to the desired folder, and click the right mouse button. In the opened context menu select Properties:

In the resulting window, click the privileges tab. Here you can change the owner and group owner by using the drop-down list opposite the appropriate paragraph:

If you need to make these changes were applied to all subfolders and files, click the bottom button to Change permissions for enclosed files…

It’s that simple. If you cannot run file Manager or you want to work in the terminal is also possible. To change the owner, use chmod utility. The syntax for it is:

$ chmod options noville:new_group /path/to/folder

Read more about this utility you can view in a separate article. For example, to change the owner of the folder ~/Videos/losst/ testuser on should execute following command:

sudo chmod testuser ~/Video/losst

In this case, the group will remain unchanged, to change the group-owner execute:

sudo chmod testuser:testuser ~/Video/losst

If you need to change the ownership of folder Linux recursively use option -R:

sudo chmod testuser:testuser ~/Video/losst

Please note that all files and folders created in the system by default will have the owner user who creates them, and a group-owner primary group of this user. This behavior cannot be changed. To avoid problems with incorrectly assigned to the folder owner in the future run a program that creates a folder or file on behalf of the user to whom the folder should belong. It is very easy with sudo. For example, for a user losst:

sudo -u losst ./

As you can see, to change the owner of folder in Linux can be very simple. It is enough to perform a few commands in the terminal, or make a few clicks of the mouse.


(Visited 7 times, 1 visits today)