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:
- Identify your current directory: Use the command
pwd(print working directory) in the terminal to see where you are. - 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 accessdocuments/file.txt, you would use:cd documents/file.txt - If you want to go up one level to
/home/and then accessuser2/file.txt, you would use:cd ../user2/file.txt
Tips:
- Always ensure you know your current directory to avoid confusion.
- Use
lsto list files and directories to verify paths.
If you have more questions or need further clarification, feel free to ask!
