bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/Bash/File Permissions
Bash•File Permissions

Bash File Permissions and Ownership

Understanding File Permissions and Ownership

In Unix-like operating systems, file permissions and ownership are crucial for managing access to files and directories.

Each file has an owner, a group, and a set of permissions that determine who can read, write, or execute the file.

File Permissions

File permissions are represented by a series of characters that indicate the permissions for the owner, the group, and others. The permissions are:

  • r : Read permission
  • w : Write permission
  • x : Execute permission

For example, the permission rwxr-xr-- means the owner can read, write, and execute the file, the group can read and execute, and others can only read.

Numeric Representation of Permissions

File permissions can also be represented numerically, which is often used in scripts and command-line operations:

  • 0 : No permission
  • 1 : Execute permission
  • 2 : Write permission
  • 3 : Write and execute permissions
  • 4 : Read permission
  • 5 : Read and execute permissions
  • 6 : Read and write permissions
  • 7 : Read, write, and execute permissions

For example, the numeric permission 755 means the owner can read, write, and execute (7), and the group and others can read and execute (5).

File Ownership

Each file has an owner and a group associated with it. The owner is typically the user who created the file, and the group is a collection of users who share access to the file.

Commands like chown and chgrp are used to change the ownership and group of a file, respectively.

Common Commands

Here are some common commands for managing file permissions and ownership:

  • chmod : Change file permissions
  • chown : Change file ownership
  • chgrp : Change group ownership

Chapter

Back to File Permissions

Next

Bash chmod Command - Change File Permissions

This chapter

Overview
4

Lessons

8m

Read time

1. Bash File Permissions and Ownership2. Bash chmod Command - Change File Permissions3. Bash chown Command - Change File Ownership4. Bash chgrp Command - Change Group Ownership

On this page

Understanding File Permissions and OwnershipFile PermissionsNumeric Representation of PermissionsFile OwnershipCommon Commands