What is the purpose of `.` in paths?

QuestionsQuestions8 SkillsProDec, 20 2025
0124

Great question! In Linux, the . (dot) character has a specific meaning when used in file paths:

The Current Directory

The single dot . represents the current directory you are currently working in.

Whenever you see ./ at the beginning of a path, it tells the system: "Look right here in the folder I am already in."

Why do we use it?

  1. Running Scripts or Programs: If you have a script in your current folder, Linux won't run it just by typing its name (for security reasons). You have to type ./script_name to tell Linux, "Run the file named script_name located in this current directory."
  2. Relative Paths: It makes it clear that you are referring to a path relative to where you are, rather than searching the whole system.

While you're learning about the single dot, it's helpful to know about the double dot:

  • . = Current directory.
  • .. = The Parent directory (one level up).

Example

If you are inside /home/labex and you want to look at a file in that same folder:

  • cat ./file1 is the same as just typing cat file1.

In your current lab, you are using absolute paths (starting with /), but as you progress, you'll find . helpful for navigating folders more quickly

0 Comments

no data
Be the first to share your comment!