2018-11-08 10:05:48 +00:00
|
|
|
---
|
|
|
|
layout: page
|
|
|
|
category: Filesystem
|
2018-11-09 07:13:40 +00:00
|
|
|
tags: absolute relative path
|
2018-11-08 10:05:48 +00:00
|
|
|
author: Marwan Announ
|
|
|
|
title: fs
|
|
|
|
---
|
|
|
|
|
2018-11-08 09:55:57 +00:00
|
|
|
<h1>Absolute Path!</h1>
|
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
<h2>First, what is a path?</h2>
|
2018-11-08 09:55:57 +00:00
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
<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>
|
2018-11-08 09:55:57 +00:00
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
<h3>Now, I can tell you what is an absolute path</h3>
|
2018-11-08 09:55:57 +00:00
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
<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>
|
2018-11-08 09:55:57 +00:00
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
<h4>To write an absolute path-name:</h4>
|
2018-11-08 09:55:57 +00:00
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
<p>
|
|
|
|
Start at the root directory ( / ) and work down.
|
|
|
|
<br>Write a slash ( / ) after every directory name (last one is optional)
|
|
|
|
</p>
|
2018-11-08 09:55:57 +00:00
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
<h5>Example:</h5>
|
2018-11-08 09:55:57 +00:00
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
<p> cat group1.txt </p>
|
|
|
|
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
|
2018-11-08 09:55:57 +00:00
|
|
|
<br> the file is saved.
|
|
|
|
<br> Now, we supposed that you know where your file is saved you can rewrite the command.
|
2018-11-09 07:13:40 +00:00
|
|
|
<p> cat /home/a1/group1.txt</p>
|
2018-11-08 09:55:57 +00:00
|
|
|
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.
|
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
As you can see from the last commands, all the paths started from /directory whis is a root directory for every Unix
|
|
|
|
machines.
|
2018-11-08 09:55:57 +00:00
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
<p> Other examples, where all are absolute path</p>
|
2018-11-08 09:55:57 +00:00
|
|
|
|
|
|
|
/home/user/Document/group1.txt
|
|
|
|
/root/data/dev.jpg
|
|
|
|
/var/log/messages
|
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
<h5>Example of Absolute path's uses:</h5>
|
|
|
|
Now, as we learned from the previous pages we can use other commands in addition to "cat", such as:
|
2018-11-08 11:43:39 +00:00
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
<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
|
2018-11-08 11:43:39 +00:00
|
|
|
|
|
|
|
<h6> Now I will show you in many examples.</h6>
|
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
and so on.. with the sintax like above.
|
2018-11-08 11:43:39 +00:00
|
|
|
|
2018-11-09 14:09:49 +00:00
|
|
|
<!-- <p>
|
2018-11-09 07:13:40 +00:00
|
|
|
<img src="0.1.jpg" alt=" ls of /etc without"/>
|
|
|
|
</p>
|
2018-11-08 11:43:39 +00:00
|
|
|
|
2018-11-09 07:13:40 +00:00
|
|
|
<p>
|
|
|
|
<img src="0.2.jpg" alt=" cd /tmp (go to tmp yuppyy)"/>
|
2018-11-09 14:09:49 +00:00
|
|
|
</p> -->
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-08 11:43:39 +00:00
|
|
|
|
2018-11-09 14:09:49 +00:00
|
|
|
<!-- quiz in javascript about absolute and what the user know after the reading-->
|