In Linux operating system, there are three types of owners;
- 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.
- Group: A group can contain multiple users. All the users belonging to a group have same access permission for a file.
- 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.
In this guide, we will see how to achieve basic file security through file ownership in our Linux system
user owner and group owner
The users and groups of a system can be locally managed in /etc/passwd and /etc/group, or they can be in a NIS, LDAP, or Samba domain. These users and groups can own files. Actually, every file has a user owner and a group owner, as can be seen in the following screenshot.
In here, the root user own 2 files.
listing user accounts
You can use the following command to list all local user accounts.
#cut -d: -f1 /etc/passwd | column
chgrp
You can change the group owner of a file using the chgrp command.
#chgrp <group name> <filename>
chown
The user owner of a file can be changed with chown command.
#chown <user> <filename>
You can also use chown to change both the user owner and the group owner.
#chown <user>:<group name> <filename>
list of special files
When you use ls -l, for each file you can see ten characters before the user and group owner. The first character tells us the type of file. Regular files get a –, directories get a d, symbolic links are shown with an l, pipes get a p, character devices a c, block devices a b, and sockets an s.
Below a screenshot of a character device (the console) and a block device (the hard disk).
And here you can see a directory and a regular file.
Latest posts by Ruwantha Nissanka (see all)
- 4 ways to hide your identity using linux - January 18, 2021
- How To Install Kali Linux in Virtualbox - December 31, 2020
- Kali Linux : The OS That Hackers Use - December 31, 2020
- How to monitor user activity in Linux with Acct - December 30, 2020
- Debsecan : You will not miss another security update - December 28, 2020