5fb1cf8adf
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@180 a672b425-5310-4d7a-af5c-997e18724b81
76 lines
2.3 KiB
HTML
76 lines
2.3 KiB
HTML
---
|
|
layout: page
|
|
category-page: fs
|
|
category-title: FileSystem
|
|
tags: absolute relative path
|
|
author: Marwan Announ
|
|
title: paths
|
|
---
|
|
<p>
|
|
<h1>Absolute Path</h1>
|
|
|
|
<h2>First, what is a path?</h2>
|
|
|
|
<p>
|
|
A path is a location to a folder or file in a file system of a Operating System, then is a combination of characters
|
|
and "/"
|
|
</p>
|
|
|
|
<h3>Now, what is an Absolute path?</h3>
|
|
|
|
|
|
<p>
|
|
An absolute path is defined as specifying the location of a file or directory from the root directory(/).
|
|
In other words we can say absolute path is a complete path from start of actual filesystem from / directory.
|
|
</p>
|
|
|
|
<h4>To write an absolute path-name:</h4>
|
|
|
|
<pre> <p>
|
|
Start at the root directory ( / ) and work down.
|
|
<br>Write a slash ( / ) after every directory name (last one is optional)
|
|
</p> </pre>
|
|
|
|
<h5>Example:</h5>
|
|
|
|
<pre> <p> cat group1.txt </p> </pre>
|
|
if for example, we use the above line, this commands work only and only if the "group1.txt" exist in the current
|
|
directory.
|
|
<br> If not works, it's not a problem, the file is present somewhere, before restart the new command, you have to
|
|
know where
|
|
<br> the file is saved.
|
|
<br> Now, we supposed that you know where your file is saved you can rewrite the command.
|
|
<p> cat /home/a1/group1.txt</p>
|
|
Now, we suppose that the file is saved into folder a1 in home,
|
|
<br>where: /home is the location respect to root, in fact, you have to descend one level
|
|
<br>in the file system like above to access your file.
|
|
|
|
As you can see from the last commands, all the paths started from /directory whis is a root directory for every Unix
|
|
machines.
|
|
|
|
<p> Other examples, where all are absolute path</p>
|
|
<pre>
|
|
/home/user/Document/group1.txt
|
|
/root/data/dev.jpg
|
|
/var/log/messages</pre>
|
|
|
|
<h6>Example of Absolute path's uses:</h6>
|
|
Now, as we learned from the previous pages we can use other commands in addition to "cat", such as:
|
|
|
|
<pre>
|
|
<br>ls /etc
|
|
<br>ls /usr/share/games if you have games obviously :)
|
|
<br>cd /usr/share/games
|
|
<br>cd ~
|
|
<br>cat /etc/passwd
|
|
<br>cp /etc/passwd /tmp
|
|
<br>cd /tmp
|
|
<br>cat passwd
|
|
</pre>
|
|
|
|
<br><br><br> <h7> Read this if you are not Bill Gates, so read this.. </h7>
|
|
|
|
<p> So, if you dont't understand anything like me before this writing, you have to know that: Absolute pathnames start with a
|
|
<br>slash on the left(simplyfied version..).
|
|
<br>For example etc/passwd is a good example of Absolute pathnames.
|
|
</p>
|