LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-30-2016, 03:13 AM   #1
hexle
LQ Newbie
 
Registered: Jun 2016
Posts: 12

Rep: Reputation: Disabled
absolute paths .Relative paths .I dont know where am i wrong


Exercise:You have http://imgur.com/a/pYoVx this image.Circles are files and the rectangle are archives.The files (5 ) , (8 ) ,(11 ) ,(25 ) are home directories the users bob,alice,studin,cat respectively.(he means (5) file is home directory from user bob,(8) file is home directory alice, (11) file is home directory studin and the file (25) is home directory cat ).''Near'' in every object there is one number which number isnt part of that name.
You must mark which one is ''right and absolute path" ,"right and relative path","false path".
In every case are given different conditions (who user are and which we have for current directory)
Questions:
1) .home/bob/file1 (we are bob with cwd the file 11)
2) /~/ ( we are bob with cwd the file 8)
3) ~bob/file2 (we are studin with cwd the file 17)
4) $ΗΟΜΕ/../guests/studin/d1 (we are bob with cwd the file 5)
5).studin/d1/file2 (we are studin with cwd the file 24)
6)/../bob/file1 (we are bob with cwd the file 8)
7)etc/passwd (we are studin with cwd he file 2)
8)cd/home/bob/file1 (we are bob with cwd the file 1)
9)~/d1/file1 (we are bob with cwd the file 2)
10) ../guests/studin/d1/file2 (we are bob with cwd the file 5)

my answers :
1)right and absolute path.Explain : . means that i am in current so it start / (slash).What is start with /(slash) is absolute path.
2)right and absolute path.Explain: start with / (slash) after ~ (that means the user home directory of a user) and it ends with /(slash)
3) right and relative path.Explain :start ~bob tha mean i am user bob
4)false path.It cant be start with $
5)right and relative path.Explain : . means that i am in studin
6)right and absolute path.explain : start with / and after .. that means the next file
7)right and relative path
8)false path.Exaplain : I dont beleive it start with cd( cd file1 and it goes us to file1 ,but here it has cd/home it think it doesnt move me there).
9)right and relative path.Explain : ~ refers to studin after there is a / (slash) ater a file d1 and /(slash) another file named file1
10) right and absolute.Explain:i am not sure about this two .. as far as i know it goes from tree one ''step lets say file down''.
 
Old 08-30-2016, 04:49 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,514

Rep: Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436
(some comments)

.home does not exist anywhere, that is false anyway
.studin as well
$HOME (and any variable should be evaluated) is usually /home/<user>, so that is valid
~ is equal to $HOME (of the current user)
~bob is equal to $HOME of the user bob
/~ is not evaluated as home of anyone, so it is /~ as is and does not exist
 
Old 08-30-2016, 01:45 PM   #3
hexle
LQ Newbie
 
Registered: Jun 2016
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
(some comments)

.home does not exist anywhere, that is false anyway
.studin as well
$HOME (and any variable should be evaluated) is usually /home/<user>, so that is valid
~ is equal to $HOME (of the current user)
~bob is equal to $HOME of the user bob
/~ is not evaluated as home of anyone, so it is /~ as is and does not exist
if i understand good.
the answer 1) is false and the answer 5) is also false(its the same case thats why) .
What about the answer 4) ? as i understand there is $HOME but after should be follow by user like this you mention /home/<user>.In this case it has $HOME/../guests that means is false?Is false because it hasnt after the user?
Also, "~bob is equal to $HOME of the user bob" what i understand is the same case but there its false? its false and this because after hasnt the /<user> ? this sentence is false ~bob/file2?i understand right?
The last "/~ is not evaluated as home of anyone, so it is /~ as is and does not exist" you refer to the second question ,this question 2) /~/ ( we are bob with cwd the file 8) .As i understand its false because after /~/ it should have user.It should be like this /~/<user> .Am i right?
 
Old 08-30-2016, 01:55 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,425

Rep: Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826
You are asking many questions but I am wondering what have you tried? Why not try and execute the lines and see what happens. If you read through your error messages none of the examples appear to be particularly difficult. I would also suggest breaking each path down and seeing if the whole path is the issue or maybe just a piece of it, for example:
Code:
~/d1/file1

#if I perform ls starting from the left on my computer I get the following
$ ls ~
bin/  Desktop/  distro/  Documents/  Downloads/ my_mirror  Pictures@
$ ls ~/d1
ls: cannot access '/home/grail/d1': No such file or directory
The above error makes perfect sense as I have not created the directory 'd1' in my home path. in addition, I do not need to try and perform ls on the whole path as previous statement means there are also not files to be found under 'd1'. This would then mean if both the directory, 'd1', and the file, 'file1', existed that this would be a valid path expression. I will leave whether or not it is absolute or relative up to you
 
Old 08-31-2016, 06:34 AM   #5
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 813

Rep: Reputation: 195Reputation: 195
Hi hexle,

Actually circles are directories and rectangles are files.

OK
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
relative/absolute paths? mkohler Linux - Newbie 3 11-13-2010 04:45 AM
bash: ln and relative paths tortle Programming 8 05-10-2010 06:50 AM
Absolute and relative paths Gins Linux - General 6 11-08-2008 09:48 PM
periods in relative paths? kuplo Linux - Newbie 2 01-10-2006 06:19 AM
relative/absolute paths in Java djgerbavore Programming 2 10-26-2004 09:01 PM


All times are GMT -5. The time now is 09:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration