Progress: 0/62 (0%)

πŸ“„ File Types and Extensions

File Types and Extensions

In Linux, everything is a file β€” yes, everything. Not just your text documents, but also your devices, directories, even your hardware! It's like a giant filing cabinet where every single thing inside (folders, text files, printers, disks, etc.) has its own file label.

How Linux Handles File Types

Linux doesn't rely heavily on extensions (like .txt, .exe, .png) to know what a file is. Instead, it looks at the file's content and permissions. That's why a file without .txt can still be a text file β€” Linux just knows by checking inside.

file filename
πŸ“Œ Example:
file myphoto
myphoto: JPEG image data

Like opening a mystery box β€” you look inside to see what's there, not just read the label.

Common File Types in Linux

Type Description Example
πŸ“„ Regular files Text, images, executables, etc. .txt, .png, .sh
πŸ“ Directory files Containers holding other files /home, /etc
πŸ”— Symbolic links Shortcuts pointing to other files/folders (symlinks) shortcut β†’ /home/master/file.txt
βš™οΈ Device files Represent hardware (e.g., disk, USB) /dev/sda, /dev/tty
πŸ’¬ Socket files Enable communication between processes /var/run/docker.sock
πŸ“¨ Named pipes Used for inter-process communication (FIFOs) /tmp/my_pipe

Think of each type like a role in a company β€” text files are employees (doing work), directories are departments, symlinks are signposts, and devices are machines.

File Extensions (Optional but Useful)

Even though Linux doesn't need them, humans do β€” they help us quickly recognize file types.

Type Example Description
πŸ“ Text .txt, .log, .cfg, .conf Plain text or config files
πŸ’» Script .sh, .py, .pl, .rb Executable scripts (Bash, Python, etc.)
πŸ“¦ Archive .tar, .gz, .zip, .rar Compressed file collections
πŸ“ System .service, .mount, .target Used in Linux system configs
πŸ“· Image .png, .jpg, .svg Graphic files
🧠 Executable no extension Binary or script you can run directly
./install.sh

Here, install.sh is a script (sh = shell script).

Hidden Files

Any file or folder that starts with a dot (.) is hidden by default.

Examples:

  • .bashrc
  • .profile
  • .gitconfig

To see them, use:

ls -a

Like files tucked inside a hidden drawer β€” not gone, just out of sight until you look for them. These usually store user settings and configurations.

Executable Files

Some files can be run as programs if they have execute permissions.

To make a file executable:

chmod +x script.sh

Then run it:

./script.sh

Like giving a key to a person β€” only then can they open the door (execute the task).

Checking File Details

To view file details (type, size, permissions):

ls -l
πŸ“Œ Example:
-rwxr-xr-- 1 master users 1204 Oct 25 2025 script.sh

Here's what it means:

  • - β†’ regular file
  • rwxr-xr-- β†’ permissions
  • master β†’ owner
  • 1204 β†’ size in bytes
  • script.sh β†’ file name

Real-Life Pro Tip

Linux doesn't care if you rename photo.jpg to photo.txt β€” it still knows it's an image internally. So, use the file command to check real types when in doubt.

Summary Snapshot

  • Linux β†’ "everything is a file."
  • Extensions β†’ optional, not mandatory.
  • Use file command β†’ to identify type.
  • Hidden files β†’ start with .
  • Make files executable β†’ with chmod +x .

Real-life analogy

Think of Linux file types like different categories in a library:

πŸ“š Regular files β†’ The actual books (text files, images, etc.)
🏒 Directories β†’ The shelves and sections organizing the books
πŸ”— Symbolic links β†’ The index cards pointing to where books are located
βš™οΈ Device files β†’ The library machines (printers, computers, scanners)
πŸ’¬ Socket files β†’ The intercom system connecting different library departments
πŸ“¨ Named pipes β†’ The pneumatic tubes for sending requests between floors

Each serves a specific purpose in the library's organization system!

Β© All Rights preserved with Deep Cyber

Cookie Policy

This website uses cookies to ensure you get the best experience on our website.

Go It!