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 10-20-2015, 10:59 PM   #1
l0r3n
LQ Newbie
 
Registered: Oct 2015
Posts: 4

Rep: Reputation: Disabled
confused about when to use cd ~/whatever or cd /whatever


Hi everyone!

I'm confused.

Sometimes in the terminal I have to type in cd ~/ to get to the directory i want, and sometimes cd /

for example, cd /boot or cd /bin works, but cd ~/bin or cd ~/boot does not

however

cd ~/Dropbox or cd ~/Documents works, but cd /Dropbox or cd /Documents doesn't.

can someone explain this to me?

Thanks for looking at my question,

Loren
 
Old 10-20-2015, 11:13 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,848

Rep: Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823
Try this and see if it helps
Code:
echo ~
 
1 members found this post helpful.
Old 10-20-2015, 11:20 PM   #3
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 6,872

Rep: Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249
The symbol ~ means your user /home directory.

Quote:
for example, cd /boot or cd /bin works, but cd ~/bin or cd ~/boot does not
That's because there is no bin or boot directory in your /home/user directory.

Quote:
cd /Dropbox or cd /Documents doesn't.
If you are in your /home/user directory then using cd Documents will work. If you want to change to a directory which is in the directory you are using, for example /home/user which has a Documents directory, don't use the forward slash /.

It depends also on where you are starting from. If you have a directory named junk in your /home/user/Documents directory you can get to it by simply typing: cd junk IF you are in the /home/user/Documents directory. You can access anything by using the full path from anywhere in the system.

Last edited by yancek; 10-21-2015 at 10:15 AM.
 
1 members found this post helpful.
Old 10-20-2015, 11:34 PM   #4
l0r3n
LQ Newbie
 
Registered: Oct 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thank you so much.

It is quite revealing when the curtain is pulled back just a bit, and I realize how much I don't know. I didn't realize that in my original post, when the cd paths I used worked, it was because i was typing in the exact correct path. See, what I thought was happening was something magical. like by typing cd /loren for example, that i would be magically transported there, regardless of my starting point. It would be nice, but what if there where two "loren" directories, in different places, right? how would that work? luck of the draw?

Anyway, thanks.

loren
 
Old 10-20-2015, 11:37 PM   #5
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mint, OpenBSD
Posts: 11,367
Blog Entries: 12

Rep: Reputation: 2752Reputation: 2752Reputation: 2752Reputation: 2752Reputation: 2752Reputation: 2752Reputation: 2752Reputation: 2752Reputation: 2752Reputation: 2752Reputation: 2752
I've found pwd to be a useful command. It stands for print working directory and will tell you what directory you are currently in.

This page gives you a number of useful tricks for using the cd command. I am particularly fond of

Code:
cd ..  
cd -
 
  


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
confused!!! rathin2j Linux - Newbie 11 01-24-2010 06:13 PM
Confused nay Very Confused chrystlenight SUSE / openSUSE 3 08-28-2007 06:57 PM
Help - Confused Larry Webb Linux - General 4 10-15-2006 11:46 PM
Confused! javamdk Linux - Networking 2 03-19-2005 01:32 AM
Please help, I'm so confused sdat1333 SUSE / openSUSE 4 12-11-2004 10:23 PM


All times are GMT -5. The time now is 08:15 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration