DEV Community

Cover image for Understanding File Types in Linux: ls -l Demystified
Jabulani Meki
Jabulani Meki

Posted on

Understanding File Types in Linux: ls -l Demystified

If you've ever run ls -l in your Linux terminal and felt like you were staring at cryptic hieroglyphics, you're not alone. Let’s break down what that first column of characters actually means — and why it's super useful for any Linux user.


Example Output

-rw-r--r--  1 root root 18047 Dec 20  2017 alternatives.log  
drwxr-x---  2 root adm  4096 Dec 20  2017 apache2

Enter fullscreen mode Exit fullscreen mode

Decoding the First Column

The first field has 10 characters, and it tells you two key things:

  • The type of file

  • The permissions (read, write, execute) for user, group, and others

Let’s focus on the very first character, which tells us the file type:

Symbol File Type What It Means
- Regular file Text, images, binaries, compressed files
d Directory A folder that holds other files
l Symbolic link A shortcut to another file or directory
s Socket Communication between processes
p Pipe Another way for processes to talk
b Block file Talks to hardware, like hard drives
c Character file Talks to hardware, one character at a time

Real World Example Breakdown

alternatives.log

-rw-r--r--  1 root root 18047 Dec 20  2017 alternatives.log
Enter fullscreen mode Exit fullscreen mode
  • First character: - = regular file

  • Permissions: Owner can read/write, others can only read

Why This Matters

Knowing what these characters mean lets you:

  • Understand if you're dealing with a file or a folder

  • Quickly spot broken links, special devices, or hidden communication tools

  • Diagnose permission errors like "Permission denied"

TL;DR

  • Run ls -l to view file details

  • First character tells you the type of file

  • Master this and you’ll start navigating Linux like a pro

Top comments (0)