Javatpoint Logo
Javatpoint Logo

Linux File Ownership

Every Linux system have three types of owner:

  1. User: A user is the one who created the file. By default, whosoever, creates the file becomes the owner of the file. A user can create, delete, or modify the file.
  2. Group: A group can contain multiple users. All the users belonging to a group have same access permission for a file.
  3. Other: Any one who has access to the file other than user and group comes in the category of other. Other has neither created the file nor is a group member.

Users and groups can be locally managed in /etc/psswd or /etc/group.


Linux File Ownership1

Look at the above snapshot, all the listed files and directories have the same user and group that is sssit.First sssit column denotes the user and second column denotes the group.

Listing User Accounts

To know the local users account, following command can be used. It list out all the local users from the system.


Linux File Ownership2

Linux chgrp: change group

The chgrp command can be abbreviated as change group. You can change the group owner of the file using chgrp command.



Linux File Ownership3

Look at the above snapshot, earlier 'file' group was sssit. But after passing the command "chgrp php file" , we have changed the group to php (we have highlighted php just to show you).

Note: Only root user have the permissison to change the owner or group of the files in the system.

Linux chown: change owner

Command chown is used to change the owner of the file.



Linux File Ownership4

Look at the above snapshot, we have changed the owner of the file list from sssit to jtp.

Command chown can also be used to change both user owner and group.



Linux File Ownership5

Look at the above snapshot, both user owner and group are changed to jtp and php respectively.

List of Special Files

When we type ls -l command, ten characters are displayed before user owner and group. First character tells us about the type of the file.

Following are the file types:

First Character
File Type
Normal file
Symbolic link
Named pipe
Blocked device
Character device

Examples of file type:

Linux File Ownership6

Look at the above snapshot, first letter c denotes the character device and b denotes the blocked device.

Linux File Ownership7

Look at the above snapshot, first letter (-) denotes the normal file and d denotes the directory.

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA