LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 05-16-2015, 10:15 AM   #1
Yogesh24
LQ Newbie
 
Registered: May 2015
Posts: 2

Rep: Reputation: Disabled
Smile Why ./home/Desktop is incorrect and ./Desktop is correct?


I'm learning about Linux, started yesterday. I have a question which didn't clear from the book and Google. The question is what is the difference between ./ and / in terminal? I'm asking this because when i give command for example - ./home/yogesh/Desktop/Books it is showing bash: ./home/yogesh/Desktop : No such file or directory but on removing the dot it's showing /home/yogesh/Desktop/Books: Is a directory.
Again on giving command like /Desktop it showing /Desktop :No such file or directory but on adding dot before / it is giving ./Desktop: is a directory.
What is the difference between ./ and / ?
I'm sorry if i asked something foolish but I have to know it anyway. Thankyou in advance and sorry for my bad English.
 
Old 05-16-2015, 10:49 AM   #2
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
/ is the topmost directory of the filesystem (the very root)
./ stands for your current location (either your home directory or where did you navigated with "cd" command)
When you open terminal usually you starting at your home directory (/home/yogesh). So if you want to list Books directory content you have to type it either
Code:
ls /home/yogesh/Desktop/Books
or
Code:
ls ./Desktop/Books
The last will be correct if you at your home directory (/home/yogesh)

Last edited by Teufel; 05-16-2015 at 10:50 AM.
 
Old 05-16-2015, 11:07 AM   #3
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Hi:

You can also use ./ to launch a script.

Code:
./ name of script
Study command-line when you have the time.
http://linuxcommand.org/

http://linuxcommand.org/learning_the_shell.php
 
Old 05-16-2015, 11:12 AM   #4
Yogesh24
LQ Newbie
 
Registered: May 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for the reply but i did'nt get it.Why ./home/yogesh is wrong and /home/yogesh is correct ?
 
Old 05-16-2015, 11:16 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,783

Rep: Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936Reputation: 5936
Actually if you look at the output of the ls -a you will see two objects represented by dots . and .. The single . means the directory itself and .. means its parrent directory. In a nutshell the . does not contain a trailing / (look at the output of the pwd command) therefore to run a command in the current working directory you need ./

An example of the .. is if you want to move one directory up in the tree i.e from /home/yogesh/Desktop/ to /home/yogesh/ quickly you would run the command
cd ..

/home/yogesh is an absolute path where as ./home/yogesh would expand to be the /current_working_directory/home/yogesh.

Last edited by michaelk; 05-16-2015 at 11:20 AM.
 
Old 05-16-2015, 12:12 PM   #6
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Quote:
Originally Posted by Yogesh24 View Post
Thanks for the reply but i did'nt get it.Why ./home/yogesh is wrong and /home/yogesh is correct ?
It's wrong because there is no "home" subdirectory in your current working directory.
 
Old 05-16-2015, 01:42 PM   #7
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
okay, a quick intro in the file system...
say, the filesystem is a tree, that is upside down (weird, but, ride with me), then the upper most part is..."/", just that.
You could put everything in there and be done, but, that's messy, and Linux would NOT function that way. Neatness is the middle name of Linux...
All the users have a folder for their stuff (MP3's - legal I hope - pics, documents...) and since "home sweet home" goes the same for Linux, all the users have their "home" in the ..."home" folder. Located at the topmost level and thus directly attached to the root - as the slash is called...
INSIDE every "home" folder are the folders...of the users...
Correctness (and completeness) dictates mentioning the whole address:

Code:
/home/peter/Documents/resume.odt
...but...why go tru that when peter lives accross the street?

In brief...

Code:
/home/peter/Music/Waterloo.mp3
is what you feed a program that is "somewhere" on the drive, so it needs the wolde "address"...but...if the player "lives in the same folder...

Code:
./Watrerloo.mp3
...will do just as well...the "dot" in front basically means..."the guy that lives in this street"...

This picture clarifies all, if cory wanted to run at something in her folder, she'd enter

Code:
./thatProgram
but if that program is in the lib folder, she'd have to enter

Code:
/usr/lib/thatProgram
Hope that clarifies some and...welcome to Linux...

Thor

Last edited by ButterflyMelissa; 05-16-2015 at 01:49 PM.
 
  


Reply



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
ubuntu-desktop vs. kubuntu-desktop vs. xubuntu-desktop vs. lubuntu-desktop vs. unity Kenny_Strawn Ubuntu 18 05-13-2011 09:20 AM
Desktop showing the contents of home folder on desktop in fedora 8 khalchian Linux - Newbie 2 08-18-2009 08:45 AM
create a shortcut in /home/username/Desktop but not still not appear on desktop! swgiant Linux - Newbie 1 09-27-2008 11:51 AM
Desktop displays '/home/*user*' instead of '/home/*user*/desktop' campbell226 Linux - Desktop 2 08-05-2008 06:15 AM
Correct desktop resolution. Incorrect screensaver & lock resolution mybootorg Linux - General 6 05-03-2006 02:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:37 AM.

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