LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-20-2015, 09: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, 10:13 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

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

Rep: Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496
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 09:15 AM.
 
1 members found this post helpful.
Old 10-20-2015, 10: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, 10:37 PM   #5
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,349
Blog Entries: 28

Rep: Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147
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



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

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

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