What is the difference between / and ./ at the start of a file path in Linux?
- User
What is the difference between / and ./ at the start of a file path in Linux?
- Assistant
/foo/baris an absolute path, no matter where you call it from../foo/baris a relative path, meaning that if you're in/bar/baz, it will evaluate to/bar/baz/foo/bar. - User
Can you explain the difference between absolute and relative path more clearly, please?
- Assistant
In Linux you use a path to refer to a unique location in the filesystem. In Unix style pathing, a path can begin with one of many things including
/for an absolute path, or./for a relative path.An absolute path does not make any assumptions about where you are currently located on the filesystem and will always refer to the same place. It describes every step that must be taken to reach the directory from the root directory. So for example the absolute path
/home/user/Documents/means that to reach this directory you must start in the root directory/, and then travel to thehomedirectory, and then to theuserdirectory, and finally theDocumentsdirectory.By contrast, a relative path will resolve to an absolute path based on what directly you currently reside in. So for example, if your current directory is
/home/user/Documents/and you refer to the path./Project/notes, this will refer to the same location as the absolute path/home/user/Documents/Project/notes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)