Skip to main content

Linux File Permissions

Two ls options cover the everyday cases: listing details (including permissions) and showing hidden files.

Listing Files

ls -l # Long format: permissions, owner, size, date, name
ls -a # Show all files, including hidden ones

Files and directories whose name starts with a dot (.bashrc, .config) are hidden and only appear with ls -a. Both options are often combined as ls -la.

Example Output

Each ls -l line describes one entry across several columns:

-rw-r--r-- 1 user staff 1024 Apr 25 10:00 notes.txt
drwxr-xr-x 2 user staff 4096 Apr 25 09:30 projects
ColumnExampleMeaning
Permissions-rw-r--r--File type and permissions
Links1Number of hard links
OwneruserOwner of the file
GroupstaffGroup the file belongs to
Size1024Size in bytes
Date & timeApr 25 10:00Last modification time
Namenotes.txtFile or directory name

Reading the Permission Notation

An ls -l line starts with a 10-character string such as -rwxr-xr-x. It breaks down into four parts:

PositionExampleMeaning
1-File type (- = file, d = directory, l = symlink)
2-4rwxPermissions for the owner
5-7r-xPermissions for the group
8-10r-xPermissions for others

Each of the three groups uses the same three flags:

FlagMeaningEffect on a fileEffect on a directory
rreadRead the contentsList the entries
wwriteModify the contentsCreate/delete entries
xexecuteRun as a programEnter (cd) the directory

A - in place of a letter means that permission is not granted. So -rwxr-xr-x means: a regular file, the owner may read/write/execute, group and others may read and execute but not write.