Chapter 17. Users, Groups, and Permissions

The ability to control user permissions is a critical aspect of maintaining the security of any system. Users should be given only the permissions that are necessary to perform their job. This is known as the principle of least privilege.

In most cases, you will need to be the owner of a file/directory or have root/administrator privileges in order to change permissions.

Warning

Be cautious when setting file permissions. Changing permissions not only has security implications, but if done incorrectly can cause a system to become nonfunctional or vulnerable to attack.

Commands in Use

In this chapter, we introduce chmod, chown, getfacl, groupadd, setfacl, useradd, and usermod for administering Linux systems, and icacls and net for administering Windows.

chmod

The chmod command is used to change file permissions in Linux. This command can be used to change three permissions: read (r), write (w), and execute (x). The read, write, and execute permissions can be set for the user (u), group (g), and other (o) users of a file or directory.

Common command options

-f

Suppress error messages

-R

Recursively change files and directories

chown

The chwon command is used to change the owner of a file or directory in Linux.

Common command options

-f

Suppress error messages

-R

Recursively change files and directories

getfacl

The getfacl command displays the permissions and access control list (ACL) for a Linux file or directory. ...

Get Cybersecurity Ops with bash now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.