File permissions in Linux control the access rights to files and directories. These file permissions as crucial in controlling who or what can read, write, or execute a file. These permissions apply to the user or file owner, the group, and others.
Categories of Users:
1. Owner (User): The user who owns the file.
2. Group: A group of users who share the same permissions.
3. Others: All other users who are not the owner and do not belong to the group.
Types of Permissions:
1. Read (r): Permission to read the file or list the directory contents.
2. Write (w): Permission to modify the file or directory.
3. Execute (x): Permission to execute the file or access the directory.
Understanding the Permission Notation:
Permissions are displayed using a 10-character string (e.g., -rwxr-xr–):
1. First Character:
  – -: Indicates a regular file.
  – d: Indicates a directory.
  – l: Indicates a symbolic link.
  – b: Indicates a block device.
  – c: Indicates a character device.
  – s: Indicates a socket.
  – p: Indicates a named pipe.
2. Next Nine Characters:
Represent the permissions for the owner, group, and others, in three sets of three characters:
  – Owner: The next three characters (rwx in this example) show the permissions for the file owner.
  – Group: The following three characters (r-x in this example) show the permissions for the group.
  – Others: The last three characters (r– in this example) show the permissions for others.
Example: -rwxr-xr–
– -: Regular file.
– rwx: Owner can read, write, and execute.
– r-x: Group can read and execute.
– r–: Others can only read.
Changing Permissions:
Permissions can be changed using the chmod command. There are two ways to use chmod:
1. Symbolic Mode:
– Use symbols to modify permissions.
  – Example: chmod u+x file.txt adds execute permission for the owner.
2. Numeric Mode:
– Use octal numbers to set permissions.
– Each permission type is represented by a number: read (4), write (2), execute (1).
  – Example: chmod 755 file.txt sets the permissions to rwxr-xr-x:
    – 7 (4+2+1) for the owner (read, write, execute).
    – 5 (4+0+1) for the group (read, execute).
    – 5 (4+0+1) for others (read, execute).
Special Permissions:
1. Setuid (Set User ID):
– When set on an executable file, this allows users to execute the file with the permissions of the file owner.
  – Represented by an s in the owner’s execute field (rws).
2. Setgid (Set Group ID):
– When set on a directory, new files created within the directory inherit the group of the directory.
– When set on an executable file, users execute the file with the permissions of the file’s group.
  – Represented by an s in the group’s execute field (r-s).
3. Sticky Bit:
– When set on a directory, it ensures that only the file owner, directory owner, or root can delete or rename files within the directory.
  – Represented by a t in the others’ execute field (rwt).
 Examples of Using chmod:
– Symbolic Mode:
– Add execute permission for the owner: chmod u+x file.txt
– Remove write permission for the group: chmod g-w file.txt
 – Add read permission for others: chmod o+r file.txt
– Numeric Mode:
 – Set permissions to rwxr-xr–: chmod 754 file.txt Â
– Set permissions to rw-r–r–: chmod 644 file.txt
Having an understanding of managing file permissions is a key part of ensuring that proper security is maintained in a Linux system.