LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 04-13-2015, 09:05 AM   #1
dunnery
Member
 
Registered: May 2010
Location: East Stroudsburg
Distribution: Debian Jessie
Posts: 230

Rep: Reputation: 10
The terminal!


Hi guys, just trying to get my head around the terminal.
When do I need a / before my pathname? I thought / meant root? So if I'm anywhere other than root, I don't need a / before my pathname

reptiles/snakes/cobras
Or do I have to put
/reptiles/snake/cobras

Can someone please Xperia,Ian when I need to use the / command before the pathnames
Thanks guys
 
Old 04-13-2015, 09:15 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Pathnames that begin with / are absolute paths, regardless in which directory you currently are they are always pointing to the same file/directory. Pathnames without the leading / are relative to the current directory you are currently in.
 
1 members found this post helpful.
Old 04-13-2015, 09:15 AM   #3
vmccord
Member
 
Registered: Jun 2012
Location: Topeka, KS
Distribution: Mostly AWS
Posts: 71
Blog Entries: 31

Rep: Reputation: Disabled
Deep breath.

The slash indicates you are going to the top of the tree, else the terminal thinks it should start looking for the path where you are.
 
2 members found this post helpful.
Old 04-13-2015, 09:17 AM   #4
Head_on_a_Stick
Senior Member
 
Registered: Dec 2014
Location: London, England
Distribution: Debian stable (and OpenBSD-current)
Posts: 1,187

Rep: Reputation: 285Reputation: 285Reputation: 285
When you place "/" before the path, it specifies an absolute path; ie the path is read from the root partition ("/" not "/root" which is $HOME for root) rather than a relative path which is read from the current working directory.

So if you were in your user's home directory, this would specify /bin:
Code:
cd /bin
Whereas this would specify ~/bin:
Code:
cd bin
There's a much better explanation given here:
http://www.linuxquestions.org/questi...-paths-256350/
 
1 members found this post helpful.
Old 04-13-2015, 09:18 AM   #5
jonnybinthemix
Member
 
Registered: May 2014
Location: Bristol, United Kingdom
Distribution: RHEL 5 & 6
Posts: 169

Rep: Reputation: Disabled
You're right, / is root. So you'd use root if you're navigating to a path that begins from root..

If you imagine the file structure like a descending pyramid in the following example:

/
/var
/var/log

Then / is root, then var is within root, and log is within var which is in root...

So, when to use the /

If you're located anywhere in the filesystem other than the parent folder. So if your currently sitting inside /var then you can just type cd log and you will get to the log directory.

If you're anywhere else, you'll need to type cd /var/log... unless we complicate matters by using ../.. or such like..

If you're currently sat in /var/log and you wanted to change to the root directory you could type cd ../.. (.. meaning one step below) so in this example changing from /var/log to / would be two steps.. on this basis cd .. would take you to /var.

I hope that makes more sense, but I'm sure someone else will be able to explain it better than me
 
1 members found this post helpful.
Old 04-13-2015, 09:24 AM   #6
rokytnji
LQ Veteran
 
Registered: Mar 2008
Location: Waaaaay out West Texas
Distribution: antiX 23, MX 23
Posts: 7,111
Blog Entries: 21

Rep: Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474
df -h will show you where everything is sitting. Sounds to me like you have home/username installed in root /. That is why everything starts from there.

If in home/username in terminal. If one uses cd to go a directory. Then the / is not needed.
The linux file structure layout in terminal and permissions were the 1st thing I bothered to learn
which made doing anything else in terminal easy peasy.

I look at the linux file structure like a building with rooms. Root is the building.
He is also the key holder for all locks in the building.
"cd" is a persons legs to walk around in the building. And open a door in the building.
ls"" is the flashlight to look around and see what is sitting in the room and it will even say
what is locked up and what is not. Depending on what switch you set th "ls" flashlight on.

http://ss64.com/bash/cd.html

http://man7.org/linux/man-pages/man1/ls.1.html

I am sure other users will cover this ground better than I. I walk around in terminal with no fear or
exasperation. YMMV from mine.
 
1 members found this post helpful.
Old 04-13-2015, 10:03 AM   #7
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
"/" is the Linux equivalent of "C:\" in Windows. It references the root of the drive. This isn't technically accurate since each drive has its own "C:\", "D:\", "E:\", etc in Windows, while in Linux all drives/partitions are mounted in subdirectories of /, but for the purposes of this explanation, assuming one drive and one partition, it's a reasonable way to think about it.

You use "/" the same way you use "C:\", when you're referring to the absolute path of some file/directory. You leave it off when you're using the relative path to that file/directory.

You can think of it like giving somebody directions to your house. An absolute path would be like giving them your full address (123 Warlock Way, Coolcity, AB 12345). They can then look up this address in a mapping program to figure out how to get there from anywhere in the country. A relative path would be like giving them specific directions to get to your house from their house (go east on Canyon Blvd, turn left on Warlock Way, it's the 3rd house on the right).
 
2 members found this post helpful.
Old 04-13-2015, 01:26 PM   #8
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
It might be worth pointing out that root may have multiple meanings.
1) root is the username for the admin account
2) it is also the home directory name of that account, located at /root
3) the root directory is the top level of the directory hierarchy as pointed out by others.
4) the root filesystem is the partition / hard drive that is mounted under the root directory, i.e. under /
 
1 members found this post helpful.
Old 04-13-2015, 03:03 PM   #9
dunnery
Member
 
Registered: May 2010
Location: East Stroudsburg
Distribution: Debian Jessie
Posts: 230

Original Poster
Rep: Reputation: 10
Great stuff guys , thank you very much. I will soak all this up.
 
Old 04-13-2015, 04:26 PM   #10
ardvark71
LQ Veteran
 
Registered: Feb 2015
Location: USA
Distribution: Lubuntu 14.04, 22.04, Windows 8.1 and 10
Posts: 6,282
Blog Entries: 4

Rep: Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842
Hi...

Ugh, could we change the title a bit to leave out the expletive?

It would be much appreciated.

EDIT: Thanks!

Regards...

Last edited by ardvark71; 04-13-2015 at 05:08 PM. Reason: Added information.
 
3 members found this post helpful.
Old 04-14-2015, 02:22 AM   #11
Rebekah
LQ Newbie
 
Registered: Apr 2015
Location: Iowa
Distribution: Debian
Posts: 15

Rep: Reputation: 8
Hi! Have you seen this?

http://learnpythonthehardway.org/book/appendixa.html

Your question's been covered pretty well, but I like that web page because the info you're probably studying is all in one place there, so you don't have to sift through silly things like YouTube videos and so on.
 
  


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
LXer: How to create a nifty terminal theme inside a Linux terminal LXer Syndicated Linux News 0 07-03-2014 09:20 AM
not screen-blanking in terminal - what sets the idle timeout on monitor for terminal stardotstar Linux - Hardware 2 08-14-2011 05:46 AM
gnome-terminal:keyboard shortcut launches terminal with / directory default! deepclutch Linux - Desktop 1 06-21-2010 11:48 AM
Switching back to the Mandrake 9.1 desktop from terminal rdesktop terminal session marc218 Linux - General 6 02-08-2007 02:45 PM

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

All times are GMT -5. The time now is 12:58 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