How do I use relative paths?

QuestionsQuestions8 SkillsProBasic Files OperationsOct, 28 2025
073

To use relative paths, you specify the location of a file or directory based on your current working directory. Here’s how to do it:

Steps:

  1. Identify your current directory: Use the command pwd (print working directory) in the terminal to see where you are.
  2. Determine the target location: Know the path to the file or directory you want to access relative to your current location.

Common Notations:

  • .: Refers to the current directory.
  • ..: Refers to the parent directory (one level up).

Examples:

  • If you are in /home/user/ and want to access documents/file.txt, you would use:
    cd documents/file.txt
  • If you want to go up one level to /home/ and then access user2/file.txt, you would use:
    cd ../user2/file.txt

Tips:

  • Always ensure you know your current directory to avoid confusion.
  • Use ls to list files and directories to verify paths.

If you have more questions or need further clarification, feel free to ask!

0 Comments

no data
Be the first to share your comment!