File Ownership
Part of the Fundamentals section of Coddy's Terminal journey — lesson 57 of 82.
Beyond permissions, every file has an owner and a group associated with it. When you run ls -l, you can see this ownership information right after the permission string:
-rw-r--r-- 1 alice developers report.txt
│ │
│ └── Group
└──────── OwnerThe owner is typically the user who created the file, and the group allows multiple users to share access. You can change ownership using the chown command:
# Change the owner of a file
chown bob report.txt
# Change both owner and group
chown bob:staff report.txt
# Change only the group
chown :staff report.txtThere's also the chgrp command, which changes only the group:
chgrp developers project.txtChanging ownership usually requires administrative privileges. This is why you'll often see these commands used with sudo on real systems. Understanding ownership helps you control exactly who the "owner" and "group" permissions apply to when you set them with chmod.
Cheat sheet
Every file has an owner and a group. You can see this information with ls -l:
-rw-r--r-- 1 alice developers report.txt
│ │
│ └── Group
└──────── OwnerUse chown to change ownership:
# Change the owner
chown bob report.txt
# Change both owner and group
chown bob:staff report.txt
# Change only the group
chown :staff report.txtUse chgrp to change only the group:
chgrp developers project.txtChanging ownership usually requires administrative privileges (use with sudo).
Try it yourself
This lesson doesn't include a code challenge.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Directories
Create A DirectoryCopy A DirectoryMove And Rename A DirectoryDelete A DirectoryRecap - Directory Operations7File Content
Head And TailWord CountSort CommandUnique CommandGrep BasicsGrep With FlagsRecap - Text Detective2Navigation
Print Working DirectoryList FilesChange DirectoryAbsolute vs Relative PathsHome And Root DirectoryRecap - Find Your Way8Redirection
Standard OutputOverwrite To A FileAppend To A FileStandard InputStandard ErrorRecap - Log Builder11Permissions
Understanding PermissionsReading PermissionsChmod With NumbersChmod With SymbolsFile OwnershipRecap - Lock It Down6Wildcards And Patterns
The Star WildcardThe Question Mark WildcardBracket WildcardsCombining WildcardsRecap - Selective Operations9Piping
What Is A PipeChaining Two CommandsChaining Multiple CommandsPipe With GrepRecap - Data Pipeline