LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-09-2005, 02:26 PM   #1
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Rep: Reputation: 47
The ls command


Could you tell me the differences among the following commands.

$ls ../
$ls ./
$ls /



[ka@c83-250-88-135 ka]$ ls ../
ka/
The above ' ka ' is a folder under the folder ' home ' .
---------------------------------------------------------------------------------------
[ka@c83-250-88-135 ka]$ ls /
bin/ boot/ dev/ etc/ home/ initrd/ lib/ lost+found/ mnt/ opt/ proc/ root/ sbin/ sys/ tmp/ usr/ var/
[ka@c83-250-88-135 ka]$
---------------------------------------------------------------------

The following command shows all my files and folders.
[ka@c83-250-88-135 ka]$ ls ./
 
Old 06-09-2005, 02:29 PM   #2
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
/, by itself, indicates the root directory of your filesystem. It's akin to windows' C:

. indicates your current directory. You could type ls . and ls ./ get the same results. The trailing "/" just is extra visual confirmation that you're talking about a directory; bash doesn't really need it.

.. indicates the directory above your current directory. Again, the trailing / is just visual.
 
Old 06-09-2005, 02:34 PM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Gins, are you going to asking help for all Linux core commands ?


http://www.icon.co.za/~psheer/book/rute.html.gz
 
Old 06-09-2005, 02:49 PM   #4
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Original Poster
Rep: Reputation: 47
I thank keefaz and rose_bud for the replies. The information you all gave me is very important.
 
Old 06-11-2005, 02:27 PM   #5
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Original Poster
Rep: Reputation: 47
I found the following on the website mentioned by keefaz.
http://www.icon.co.za/~psheer/book/rute.html.gz


4.6 Relative vs. Absolute Pathnames

Commands can be given file name arguments in two ways. If you are in the same directory as the file (i.e., the file is in the current directory), then you can just enter the file name on its own (e.g., cp my_file new_file). Otherwise, you can enter the full path name, like cp /home/jack/my_file /home/jack/new_file. Very often administrators use the notation ./my_file to be clear about the distinction, for instance, cp ./my_file ./new_file.
The leading ./ makes it clear that both files are relative to the current directory. File names not starting with a / are called relative path names, and otherwise, absolute path names.
-----------------------------------------------------------------------------------------

I can't fathom the last two sentences of the above.

Rose_bud4201 told me the simple forward slash [ / ] is akin to Windows C: prompt. Yes I agree with him. I tested it.

On top of that he told me the dot [ . ] or [ ./ ] means your current directory. Yes I agree with him. I tested it.

I have some difficulty understanding the meaning of Relative and Absolute Pathnames. The explanations given on the website is not clear to me.

Would you be able shed some light on this?



File names not starting with / are called relative path names. What is the meaning of this? You could create a file using, for example, the ' touch ' command. I can create a file called ' America1234 ' . It doesn't have any forward slash [ / ] .

Are you able to create a file name [ /America1234 ] ? If you can create it, why use the forward slash [ / ] ?

Last edited by Gins; 06-11-2005 at 02:29 PM.
 
Old 06-11-2005, 02:36 PM   #6
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
argh!! You are SO frustrating!! You have lots to learn but asking every single question on a forum is not the way to do it!! Get yourself a decent linux book!

What it means by relative and absolute pathnames is:

relative: in relation to the current directory.
absolute in relation to the root directory (/)
For example if I do:
Code:
touch newfile.txt
it will create a file newfile.txt in whatever directory I am currently in. If I am currently in /home/steve then the absolute path will be:
Code:
/home/steve/newfile.txt
and the relative pathname would be
Code:
./newfile.txt
(./because it's in the same directory I am currently in).
If I now move to a different directory, say /home, then the absolute path does not change, it is still /home/steve/newfile.txt but the relative path is now ./steve/newfile.txt

If I now change directory to / (the root directory) the absolute pathname is still /home/steve/newfile.txt, but the relative path again changes and is now /home/steve/newfile.txt because it is relative to where I am, and I am currently at the root of the filesystem.

For a windows analogy. In windows, the file command.com is in c:\windows\system , so its absolute path is:
C:\windows\system\command.com
if I was browsing through C:\windows then at that moment the relative path of command.com is .\system\command.com

Alles klar?
 
Old 06-11-2005, 03:23 PM   #7
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Original Poster
Rep: Reputation: 47
Thank you for the beautiful explanation. As a matter of fact, I have bought a couple of books on Linux. I must buy some more books. Today I tried in vain to buy a book called ' UNIX Complete' . It was written by a person called Peter Dyson. It seems the book is out of print. I checked even at online bookshops .

One online bookshops in the UK says it is out of print at the moment. However, I borrowed it from a public library. I could keep it at home just for 4 weeks.
As far as I am concerned, when I ask questions from you all via the online forums, I learn better than reading books.



As your answer is an excellent one, I printed it out. I always print out the answers which I consider is very worth.

Last edited by Gins; 06-11-2005 at 04:35 PM.
 
Old 06-11-2005, 03:37 PM   #8
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
Wow, I've never been considered very worthy before!

And I didn't mean to appear rude, sorry.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM
Why after start of a command the invitation for input next command has not appeared. ukrainet Linux - General 3 06-24-2005 08:16 AM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM
Where is Command line utility for Cups and command tutorial mossy Linux - Software 8 01-16-2004 12:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:59 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
Open Source Consulting | Domain Registration