How do directories differ from files?

QuestionsQuestions4 SkillsProDec, 21 2025
0153

In Linux, the simplest way to think about the difference is: Files are the "stuff," and Directories are the "containers."

Here are the three main differences:

1. Purpose

  • Files: These contain actual data. Whether it's a text document, a script, an image, or a program, a file holds the information you work with.
  • Directories (Folders): These are used to organize files and other directories. They don't hold "data" in the traditional sense; instead, they hold a list of pointers to the files inside them.

2. How they appear in the terminal

When you run the ls command, you can often tell them apart by their color or symbols:

  • Directories: Usually appear in blue.
  • Files: Usually appear in white (or green if they are executable programs).

You can see more detail by using the "long listing" command:

ls -l
  • If the line starts with a d, it’s a directory (e.g., drwxr-xr-x).
  • If the line starts with a -, it’s a regular file (e.g., -rw-r--r--).

3. Actions you can perform

  • You read or edit a file (using tools like cat, nano, or vim).
  • You enter or change into a directory (using the cd command). You cannot "cd" into a file.

Try this in your current terminal: Run ls -F.

  • Directories will have a trailing slash (like project/).
  • Regular files will not have a slash.

In your current step, you are exploring how to list what is inside these "containers" (directories) using the ls command!

0 Comments

no data
Be the first to share your comment!