Fundamentals 8 min read

Master Linux File Permissions: Decode ls -l, chmod, and Links

This guide explains Linux file ownership, interprets the detailed output of ls -l, clarifies permission bits, distinguishes symbolic and hard links, and demonstrates how to change owners and permissions using both numeric and symbolic methods.

ITPUB
ITPUB
ITPUB
Master Linux File Permissions: Decode ls -l, chmod, and Links

Linux is a multi‑user, multitasking operating system where each user has a UID and GID that act like a personal ID card; file ownership and permissions determine who can read, write, or execute a file.

Understanding ls -l Output

Running ls -l in the root directory shows entries such as lrwxrwxrwx. 1 root root 7 Aug 18 21:27 bin -> usr/bin. The seven fields represent: lrwxrwxrwx. – file type and permission bits 1 – number of hard links root – owner root – group 7 – size in kilobytes Aug 18 21:27 – last modification time bin -> usr/bin – file name (and target for links)

File Type Characters

-

– regular file d – directory l – symbolic or hard link b – block device c – character device s – socket p – named pipe (FIFO)

Permission Bits

The next nine characters are grouped in triples for owner, group, and others, using r (read), w (write), and x (execute). A dash ( -) indicates the absence of that permission.

The trailing dot ( .) signals an SELinux security label; it disappears when SELinux is disabled.

Symbolic vs. Hard Links

Symbolic link (symlink) : a special file containing a path to another file or directory, similar to a Windows shortcut. Create with ln -s source target.

Hard link : another directory entry that points to the same inode as the original file. Multiple names can refer to the same data; the file persists until the last hard link is removed. Create with ln source target.

Key differences :

Both provide alternate paths to the same content.

Removing the target of a symlink invalidates it; removing a hard link only decrements the link count.

Symlinks can span filesystems and network mounts; hard links must reside on the same filesystem.

Changing Ownership

Use chown [-R] username:group filename to change the owner and/or group. The -R flag applies the change recursively to directories.

Modifying Permissions

1. Numeric Method

Permission bits are represented by octal values: read = 4, write = 2, execute = 1. Combine them for each class (owner, group, others). Example: chmod 700 filename grants full rights to the owner and none to group or others.

2. Symbolic Method

Introduce the letters u (user/owner), g (group), o (others), a (all) and the operators + (add), - (remove), = (set exactly). Example: chmod ug+w filename adds write permission for both owner and group.

Additional Topics

Hidden files : Files whose names start with a dot ( .) are not shown by default; use ls -al to list them.

Special directories : . – current directory .. – parent directory - – previous working directory ~ – current user's home directory

Special permission bits : s (setuid/setgid) and t (sticky bit) exist beyond the basic rwx set, but are rarely used in everyday operations.

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.

LinuxchmodFile PermissionsHard LinkSymbolic Link
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.