
Linux file permissions control access to files and directories, specifying which users or groups can read, write, or execute them. Understanding and managing file permissions is crucial for maintaining security and controlling access to sensitive data. Let’s dive into the basics of Linux file permissions:
1. Types of Users in file permissions:
Owner/User: The user who owns the file or directory.
Group: Users who belong to the same group as the file or directory.
Others: All other users who are not the owner or part of the group.
[devnixops@uadev home]$ ls -ld /home/devnixops
drwx------. 14 devnixops devnixops 4096 May 27 22:57 /home/devnixops
[devnixops@uadev home]$ ls -ld /root
dr-xr-x---. 4 root root 161 May 27 22:56 /root
[devnixops@uadev home]$ ls -ld /tmp
drwxrwxrwt. 19 root root 4096 May 28 18:31 /tmp
[devnixops@uadev home]$
The permission symbols are represented as follows:
r: Read permissionw: Write permissionx: Execute permissiond: Its not a permission. It represents listed object is a directory.t: sticky bit is a special permission that can be set on directories. When the sticky bit is set on a directory, only the owner of a file within that directory (or the root user) can delete or rename that file.l: link [ shortcut to another file or directory ]
2. Types of Permissions:
Read (r): Allows viewing and reading the contents of a file or listing the contents of a directory.
Write (w): Allows modifying, appending, or deleting the contents of a file, and creating, deleting, or renaming files within a directory.
Execute (x): Allows executing a file (for scripts or binaries) or traversing (entering) a directory.

3. Viewing Permissions:
Use the ls -l command to view permissions in a long format.
[devnixops@uadev etc]$ ls -lrt
-rw-r--r--. 1 root root 66 Jun 23 2020 filesystems
-rw-r--r--. 1 root root 3380 Jan 8 13:17 rsyslog.conf
drwxr-xr-x. 2 root root 6 Jan 8 13:22 rsyslog.d
-rw-r--r--. 1 root root 23 Mar 20 23:28 system-release-cpe
lrwxrwxrwx. 1 root root 14 Mar 20 23:28 system-release -> centos-release
-rw-r--r--. 1 root root 449 Apr 26 20:14 sysctl.conf
drwxr-xr-x. 4 root root 166 May 27 22:46 systemd
drwxr-xr-x. 2 root root 28 May 27 22:46 sysctl.d
drwxr-xr-x. 3 root root 4096 May 27 22:49 sysconfig
[devnixops@uadev etc]$
- The first character indicates the file type (
-for a regular file,dfor directory). - The next three characters represent owner permissions, followed by group permissions, and then permissions for others.
rindicates read permission,windicates write permission, andxindicates execute permission.
