Master Linux File Permissions: chown, chmod, and Permission Bits Explained
This guide explains how Linux manages file ownership and permissions, detailing the use of chown and chmod commands, interpreting permission bits, numeric and symbolic modes, and provides practical examples for changing owners, groups, and access rights.
Linux is a multi‑user operating system where users have different privileges.
To protect security, Linux defines separate permissions for different users on the same file or directory.
The two main commands to modify file ownership and permissions are chown (change owner) and chmod (change mode).
Use ll or ls -l to view file attributes, owner, and group.
# ls -l
total 64
drwxr-xr-x 2 root root 4096 Dec 14 2012 bin
drwxr-xr-x 4 root root 4096 Apr 19 2012 boot
...The first character indicates the file type: d for directory, - for regular file, l for symbolic link, b for block device, c for character device.
The next nine characters are three groups of rwx representing read, write, and execute permissions for owner, group, and others. A dash - means the permission is absent.
Positions 0‑9 encode the file type and permissions; positions 1‑3 are owner permissions, 4‑6 group permissions, 7‑9 others permissions. The numeric mode is the sum of r=4, w=2, x=1 for each group (e.g., 770 = rwx for owner and group, none for others).
Changing file ownership and group
chgrp – change group
Syntax: chgrp [-R] group file. The -R option applies the change recursively.
chown – change owner (and optionally group)
Syntax: chown [-R] owner file or chown [-R] owner:group file.
# cd ~
# chown bin install.log
# ls -l install.log
-rw-r--r-- 1 bin users 68495 Jun 25 08:53 install.log
# chown root:root install.log
# ls -l install.log
-rw-r--r-- 1 root root 68495 Jun 25 08:53 install.logchmod – change mode
Permissions can be set numerically or symbolically. Numeric mode is the sum of r=4, w=2, x=1 for each class.
# chmod 777 .bashrc
# ls -l .bashrc
-rwxrwxrwx 1 root root 395 Jul 4 11:45 .bashrcTo set permissions to -rwxr-xr-- (754): chmod 754 file or symbolically chmod u=rwx,g=rx,o=r file.
# touch test1
# ls -l test1
-rw-r--r-- 1 root root 0 Nov 15 10:32 test1
# chmod u=rwx,g=rx,o=r test1
# ls -l test1
-rwxr-xr-- 1 root root 0 Nov 15 10:32 test1To remove execute permission from all users: chmod a-x file.
# chmod a-x test1
# ls -l test1
-rw-r--r-- 1 root root 0 Nov 15 10:32 test1Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
