Linux

How to Chown Recursively on Linux Server

Chown is a command on Linux that is used in order to change the owner of a set of files or directories.

In this guide, we will discuss how to Chown recursively on Linux server.

Chown comes with multiple options and it is often used to change the group owning the file.

However, in some cases, you may need to change the owner of a directory with all the files in it.

For that, you may need to use one of the options of the chown command : recursive chown.

In this tutorial, you are going to learn how you can recursively use the chown command

Sponsored
to change folders and files permissions recursively.

Chown Recursively

The easiest way to use the chown recursive command is to execute “chown” with the “-R” option for recursive and specify the new owner and the folders that you want to change.

$ chown -R <owner> <folder_1> <folder_2> ... <folder_n>

For example, if you want to change the owner of directories and files contained in the home directory of a specific user, you would write

$ chown -R user /home/user

Chown User and Group Recursively

In order to change the user and the group owning the directories and files, you have to execute “chown” with the “-R” option and specify the user and the group separated by colons.

$ chown -R <user>:<group> <folder_1> <folder_2> ... <folder_n>

For example, let’s say that you want to change the user owning the files to “user” and the group owning the files to “root”.

In order to achieve that, you would run the following command

$ chown -R user:root /home/user

Congratulations, you successfully use the “chown” command recursively to change owners on your server!

Chown recursively using find

Another way of using the “chown” command recursively is to combine it with the “find” command in find files matching a given pattern and changing their owners and groups.

$ find <path> -name <pattern> -exec chown <user>:<group> {} \;

For example, let’s say that you want to change the owner for all the TXT files that are present inside a given directory on your server.

Sponsored

First of all, it is very recommended to execute the “find” command alone in order to verify that you are matching the correct files.

In this example, we are going to match all the TXT files in the home directory of the current user.

$ find /home/user -name *.txt

Now that you made sure that you are targeting the correct files, you can bind it with the “chown” in order to recursively change permissions.

$ find /home/user -name *.txt -exec chown user {} \;

As you can see, the owner of the TXT files were changed, yet none of the other files and directories were altered.

Being careful with recursive chown

On Linux, executing commands such as chown, chmod or rm is definitive : there is no going back.

As a consequence, you will have to be very careful not to execute any commands that will harm your system.

This point is illustrated in the previous section : we run the find command alone and we made sure it was the correct result.

Then, we executed the chown command in order to recursively change files permissions from the previous command.

As a rule of thumb : if you are not sure of the output of a command, divide it into smaller pieces until you are sure that you won’t execute anything harmful.

Conclusion

In this tutorial, you learned how you can execute the chown command recursively on your system.

You learned that you can achieve it using the “-R” option or by combining it with the find command.

Also, if you are interested in Linux System Administration, be sure to check out the Linux Administration Knowledgebase at Rad Web Hosting.

Ubuntu Server Admin

Recent Posts

Canonical achieves IEC 62443-4-1 compliance in Industrial Automation and Control Systems

Canonical is proud to announce it has achieved compliance with IEC 62443-4-1 for cybersecurity in…

10 hours ago

VirtualBox 7.2.2 Fixed TPM 2.0 Emulation & KVM Conflict

Oracle VirtualBox, announced the first maintenance update for the 7.2 release series few days ago.…

2 days ago

Firefox 143.0 is out with Microsoft Copilot AI Integration

Firefox 143.0, the new monthly release of the popular free open-source web browser, is available…

2 days ago

VLC 3.0.22 Adds Qt6 & AMD AI Frame Interpolation Support [Ubuntu PPA]

VLC, the popular free open-source media player, rolled out the new 3.0.22 version few days…

2 days ago

Dash to Panel updated with GNOME 49 (Ubuntu 25.10) Support

Dash to Panel, the popular Gnome Shell extension, updated few days ago with support for…

3 days ago

Ubuntu Weekly Newsletter Issue 909

Welcome to the Ubuntu Weekly Newsletter, Issue 909 for the week of September 7 –…

3 days ago