FactorPad
Build a Better Process

Linux chown Command Summary with Examples

Linux chown allows you to change file owner and group.
  1. Purpose - Learn what chown is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with chown.
  4. A tip - Finish off with one more insight.
face pic by Paul Alan Davis, CFA
Updated: February 24, 2021
In this tutorial on Linux chown, 76 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / chown-command.html


An ad-free and cookie-free website.


Examples of the Linux chown Command

Beginner

Learn to change a file's owner and group at the Linux command line.

Video Tutorial

Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux chown Command Summary with Examples (3:39)

Video Script

The Command and Why You Need It

Our seventy-sixth word, or command to memorize is chown from our category Users.

chown allows you to change file owner and group.

Common Linux chown Options
-options description
-h, --help Print help screen
-R, --recursive Apply to files within directories recursively

Recall from the previous video (tutorial) on chmod, we learned how to change file permissions for the owner, group and world. Now we'll make changes to the owner of the file itself, so the new owner can make changes.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The chown command has 14 options, the first argument is the new owner, then colon : then the new group and the file or directory.

Like most commands, help is available with double-dash --help. The -r option applies changes to directories recursively.

So why is chown an important command? Well, since the file or directory owner has additional rights, it's important to know how to make ownership changes. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. Let's start by viewing a new empty file I created using the touch command for this video and I called it video76.txt and the owner is paul and group is paul.

$ ls -l video76.txt -rw-r--r-- 1 paul paul 0 Nov 8 13:41 video76.txt

Oh, also while I'm here, I won't do it now, but when you have time, do a cat /etc/group to see a listing of groups on your system.

Okay, next let's change the owner and group to the root user using chown root:root video76.txt and Enter.

$ chown root:root video76.txt

And last, let's verify with ls -l for the long format, on video76.txt that shows two additional columns.

$ ls -l video76 -rw-r--r-- 1 root root 0 Nov 8 13:41 video76.txt

And it looks like it was changed.

A Final Tip

Okay now you know how to use chown. And you know the syntax for commands, options and arguments.

One last tip about the chown command. So there is a legacy command chgrp, used to change groups before the functionality was added to chown. And so you don't really have to look that one up or memorize it. It just gives you one less command to think about.

Okay, thanks for visiting today. I hope this was a helpful introduction to the chown command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

Be part of our growing family. Subscribe, follow and join.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / chown-command.html


chown owner
chown command
linux chown
chown linux
chown example
change owner linux
linux change owner
chown group
change permissions linux
file permissions linux
chown recursive
chown directory
linux permissions
sudo chown
chgrp command

A newly-updated free resource. Connect and refer a friend today.