FactorPad
Faster Learning Tutorials

Linux chown command summary with examples

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.
Paul Alan Davis, CFA, November 8, 2016
Updated: July 25, 2018
In this tutorial, 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 Next

~/ home  / tech  / linux essentials  / chown command


The Linux chown command

Beginner

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

Video Tutorial

Linux chown command summary with examples (3:39)

Videos can also be accessed from the YouTube Playlist.

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.

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 on YouTube. Subscribe here.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the chmod command, hit Back.
  • To further explore users and groups with the id command, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / chown command



 
 
Keywords:
Linux chown command
change owner
chown command
chown example
Linux file permissions
change owner
Linux change group
sudo chown
chgrp command
chown group
chown recursive