Mastering Linux File Permissions and User Management: From ls -l to sudo

This guide explains how Linux enforces security through file permissions, detailing the meaning of ls -l output, the numeric and symbolic chmod methods, the role of root and sudo, and how to manage users and groups with chown, adduser, and usermod.

Ubuntu
Ubuntu
Ubuntu
Mastering Linux File Permissions and User Management: From ls -l to sudo

1. Understanding the ls -l output

Running ls -l shows a line such as drwxr-xr-x 2 user user 4096 Jan 1 12:00 Documents. The first column ( drwxr-xr-x) encodes the file type and permission bits.

1st character : file type – d for directory, - for regular file.

2nd‑4th characters (rwx) : permissions for the owner .

5th‑7th characters (r-x) : permissions for the group .

8th‑10th characters (r-x) : permissions for others .

Meaning of the rwx bits

r

(Read): view file contents or list directory entries. w (Write): modify file contents or create/delete entries in a directory. x (Execute): run a file as a program or enter a directory.

2. Changing permissions with chmod

chmod

(Change Mode) modifies file permissions. Two common syntaxes are provided.

Numeric method (most common)

r = 4, w = 2, x = 1, none = 0.

Example: chmod 755 file sets owner to rwx (7), group to r-x (5), others to r-x (5).

Symbolic method

Specify target: u (user/owner), g (group), o (others), a (all).

Operation: + add, - remove, = set exactly.

chmod +x script.sh    # add execute permission for everyone (most common)
chmod u+w file.txt    # add write permission for the owner
chmod o-r secret.txt  # remove read permission from others

3. Superuser: Root and sudo

The root account can perform any action, including deleting the entire system. Ubuntu locks the root account by default; regular users obtain temporary admin rights with sudo.

When to use sudo? Installing software, changing system configuration, or editing files under /etc.

How to use it? Prefix the command with sudo, e.g.:

sudo apt update

The system prompts for the user's password (no asterisks are shown).

A practical habit: avoid sudo when possible. Many “permission denied” issues stem from incorrect file ownership or group; fix them with chown before adjusting permissions with chmod.

4. User and group management

chown (Change Owner)

Changes the owner (and optionally the group) of a file or directory.

sudo chown user:group file.txt
sudo chown -R user:user /var/www/html   # recursive change

adduser / useradd

Creates a new user. adduser provides an interactive wizard and is recommended.

sudo adduser newuser

usermod

Modifies user attributes, commonly used to add a user to the sudo group for admin privileges.

sudo usermod -aG sudo newuser

Conclusion

Understanding Linux permissions clarifies why Linux is generally more secure than Windows: a program cannot run unless the appropriate chmod bits allow it.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxUser ManagementchmodchownFile Permissionssudo
Ubuntu
Written by

Ubuntu

Focused on Ubuntu/Linux tech sharing, offering the latest news, practical tools, beginner tutorials, and problem solutions. Connecting open-source enthusiasts to build a Linux learning community. Join our QQ group or channel for discussion!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.