How to use the Chown command in Linux?

Before going into how to use the chown command, let’s start by reviewing the basic syntax. The chown command expressions take the following form: chown [OPTIONS] USER[:GROUP] FILE(s) USER is the user name or the user ID (UID) of the new owner. GROUP is the name of the new group or the group ID (GID).

How to change the owner of a file using Chown command?

The chown command –from option lets you verify the current owner and group and then apply changes. Then chown changed the owner to linuxuser and the group to group3. The option –from can be used to validate only the current user of a file. Similar to the previous section, you can validate only the group of a file using the option –from.

How to change the ownership of multiple files or directories in Linux?

To change the ownership of multiple files or directories, specify them as a space-separated list. The command below changes the ownership of a file named file1 and directory dir1 to a new owner named linuxize:

How to copy settings from one file to another in Linux?

Add the –reference option to the chown command to copy the settings from one file to another: Remember to type in the names of the files correctly to avoid the error message: The chown command –from option lets you verify the current owner and group and then apply changes.

How to change the ownership of a file using Chown command?

The chown command changes the user and/or group ownership of for given file. The syntax is: In this example, change only the group of file. To do so, the colon and following GROUP-name ftp are given, but the owner is omitted, only the group of the files is changed:

What is the difference between -H and -L in Chown command?

If the argument passed to chown command is a symbolic link that points to a directory, the -H option will cause the command to traverse it. -L tells chown to traverse each symbolic link to a directory that is encountered. Usually, you should not use these options because you might mess up your system or create a security risk.

How do I check the Chown version on my Machine?

To check the chown version on your machine, enter: The output will look similar to this: First, you need to know the original file owner or group before making ownership changes using the chown command. To check the group or ownership of Linux files and directories in the current location, run the following command:


You Might Also Like