** Table of Contents**

Description: Learn how to view and change file and directory permissions in Linux using chmod, chown, and chgrp with simple examples.

Linux controls access to files and directories using a permission system. Knowing how to check, change, and manage these permissions is essential for keeping your system secure and organized.

This guide breaks down the basics of file permissions and how to manage them using chmod, chown, and chgrp.

Business Use Case

Imagine you're a DevOps engineer at a company where multiple developers are working on different microservices. You want to ensure that

  • Each team has access only to their own service folder
  • No unauthorized user can modify critical deployment scripts
  • Logs are readable but not editable by non-admin users

What Are File Permissions?

File permissions in Linux control who can read, write, or execute a file or directory. These are usually defined for:

  • User (u) – The file owner
  • Group (g) – The group the file belongs to
  • Others (o) – Everyone else

Types of Permissions

Linux supports three main types of permission systems:

  1. Basic Permissions – Most commonly used; includes r (read), w (write), and x (execute).
  2. ACL (Access Control List) – More advanced, allowing fine-grained control.
  3. Special Permissions – Includes setuid, setgid, and sticky bit (covered in later parts).

Check File and Directory Permissions

Check permissions of a file
ls -l filename to show the permission of a particular file

Image description

ls -ld Desktop - show the permissions of the Desktop directory.
Image description
Each part indicates permission for user, group, and others.

Change Ownership of Files or Directories

Change file/directory owner
chown username file_or_dir
Image description
From the screenshot the owner was student but the the command chown root file222.txt the own was changed to root.

Change group ownership
chgrp groupname directory - This command changes the group the directory belongs to.
Image descriptionImage description

Change both owner and group
chown user:group directory - This command changes both the owner and group of the directoryImage descriptionImage description

Change File Permissions with chmod

Remove Permissions

Command Description
chmod o-rwx dir Remove all permissions from others
chmod g-rx dir Remove read and execute from group
chmod u-w dir Remove write permission from user

i. chmod o-rwx food/ - remove all permissions from other to the food directory.Image descriptionii.chmod g-rx dir1/ - remove read and execute permission from groupImage descriptioniii.chmod u-w gitclone/ - remove the write permission from the user.Image description

Add Permissions

Command Description
chmod u+rwx dir Give user full permissions
chmod ugo+rwx dir Give all users full permissions

i.chmod u+rwx dir1/ - this command will add read, write and execute permissions to dir1 directory.Image descriptionImage descriptionii.chmod ugo+rwx food/Image description

Set Full or Specific Permissions

Command Description
chmod u-rwx,g-rwx,o-rwx dir1/ Remove all permissions from everyone
chmod ugo=r-x dir Set read and execute permissions for all

i.chmod u-rwx,g-rwx,o-rwx dir1/Image descriptionii.chmod ugo=r-x dirImage description

Numeric Value of PermissionImage description

Each digit in a three-digit permission set (like 755) represents:
1st digit: User (owner)
2nd digit: Group
3rd digit: Others

Conclusion

File and directory permissions are one of the most important parts of Linux system administration. Learning how to check and set the right permissions helps keep your files secure and your system under control.
Practice with test files and get comfortable using chmod, chown, and ls -l.