Fundamentals 9 min read

Mastering Unix/Linux File System Layout and Permissions: A Practical Guide

This article explains the standard Unix/Linux directory hierarchy, the seven file types, how to inspect file types and permissions with ls, the meaning of permission bits, octal codes, and practical chmod examples for managing file access.

ITPUB
ITPUB
ITPUB
Mastering Unix/Linux File System Layout and Permissions: A Practical Guide

Standard Directories

The Unix/Linux family follows a loosely defined but widely adopted directory layout that can be used as a reference when placing files. The most common top‑level directories are:

/bin : Core operating‑system commands.

/boot : Kernel and files needed to boot the system.

/dev : Device nodes for pseudo‑terminals, disks, printers, etc.

/etc : Critical startup and configuration files.

/home : Default home directories for regular users.

/kernel : Kernel components (specific to some systems).

/lib : Shared libraries and parts of the C compiler.

/media : Mount points for removable media.

/mnt : Temporary mount points for removable media.

/opt : Optional application packages (not universally used).

/proc : Information about running processes.

/root : Home directory of the super‑user.

/sbin : Minimal set of commands required for system operation.

/stand : Stand‑alone tools such as disk‑formatting utilities.

/tmp : Temporary files that disappear on each reboot.

/usr : Hierarchy for secondary files and commands.

/usr/bin : Most user‑level commands and executables.

/usr/include : Header files for C compilation.

/usr/lib : Libraries used by standard programs.

/usr/lib64 : 64‑bit libraries on 64‑bit Linux distributions.

/usr/local : Locally compiled or installed software; mirrors the /usr structure.

/usr/sbin : Less critical system‑administration commands.

/usr/share : Architecture‑independent shared data.

/usr/share/man : Online manual pages.

/usr/src : Source code for non‑local packages (rarely used).

/usr/tmp : Persistent temporary space across reboots.

/var : Variable data such as logs and spool directories.

/var/adm : Miscellaneous administrative records and logs.

/var/log : System log files.

/var/spool : Spool directories for printers, mail, etc.

/var/tmp : Additional temporary space that survives reboots.

File Types

Regular file

Directory

Character device file

Block device file

Local socket

Named pipe (FIFO)

Symbolic link

Viewing File Types with ls

Run ls -ld <path> to see the file type code in the first character of the output. Example:

$ ls -ld /usr/include

drwxr-xr-x 257 root wheel 8738 ... /usr/include

The leading d indicates that /usr/include is a directory.

File Permissions

Use ls -ld <file> to view permission bits. Example output: -rw-rw-r-- 1 hope 123 Feb 03 15:36 file.txt The first character ( - ) shows a regular file; d would indicate a directory. The next three groups of characters represent permissions for the owner, the group, and others respectively:

rw- (binary 110, octal 6) – read and write.

rw- (binary 110, octal 6) – read and write for the group.

r-- (binary 100, octal 4) – read‑only for others.

Combined, the permissions can be expressed as the octal number 664 .

Octal Permission Codes

0 – ---

1 – --x

2 – -w-

3 – -wx

4 – r--

5 – r-x

6 – rw-

7 – rwx

Changing Permissions with chmod

To give another file the same permissions as file.txt, run: chmod 664 abcfile.txt The symbolic mode of chmod allows more readable changes. Common symbols: u+w – add write permission for the owner. ug=rw,o=r – set read/write for owner and group, read‑only for others. a-x – remove execute permission from all classes. ug=srx,o= – set setuid and setgid bits, give owner and group read/execute, remove all permissions for others. g=u – make the group permissions identical to the owner’s.

Mnemonic meanings of the classes:

u – user (owner)

g – group

o – others

a – all (u, g, and o)

Visual Aids

ls command file type codes
ls command file type codes
chmod permission encoding
chmod permission encoding
chmod mnemonic examples
chmod mnemonic examples
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.

LinuxUnixfile systemlschmod
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.