Pcornel
Linux · Filesystem

File Types

Cheat sheet · https://pcornel.dk/topic.php?topic=2677

Back to the Topic

Answer

Linux file types are regular files (-), directories (d), symbolic links (l), character devices (c), block devices (b), named pipes (p) and sockets (s). The first character of ls -l shows the type.

Remember

file looks at content (text, ELF binary, script), while ls -l and stat show the filesystem type. Do not copy or edit device files or sockets as if they were regular files.

First checks

  • file <path> — content type
  • stat -c %F <path> — filesystem type in words
  • ls -ld <path> — owner, permissions and type
  • stat <path> — inode, links, size and timestamps
  • df -h <path> — filesystem and free space
  • findmnt <path> — which mount the path is on

Verify in this order

directory entry → inode type → kernel handles it as file, directory, link, device, pipe or socket

Where it usually breaks

First mismatch in hardware/block device → kernel driver/mapper/RAID/LVM → filesystem → mount namespace/options → path permissions/MAC → consumer I/O; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2677

Confirmation

Confirm action

Continue?