3
sign up log in tour help Take the 2-minute tour × Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required. How do I navigate between directories in terminal? I am new to Linux and Ubuntu and have tried changing to folders/directories with some difficulty. Could someone explain why the following commands failed to change to the desired target folder/directory? sharon@sharon:~$ cd Home bash: cd: Home: No such file or directory sharon@sharon:~$ cd /Home bash: cd: /Home: No such file or directory sharon@sharon:~$ cd Documents sharon@sharon:~/Documents$ cd Downloads bash: cd: Downloads: No such file or directory sharon@sharon:~/Documents$ cd /Downloads bash: cd: /Downloads: No such file or directory sharon@sharon:~/Documents$ command-line directory edited Dec 25 '12 at 7:44 Dec 25 '12 at 7:44 Sergey 22.9k 1 46 67 asked Dec 24 '12 at 21:18 Dec 24 '12 at 21:18 n00b 467 4 8 25 4 Answers The filesystem is GNU/Linux is like a tree, except that the root is on top. :-) So you have structure like: / bin/ home/ sharon/ Documents/ Downloads/ fileA.txt fileB.jpg usr/ var/ If you want to move inside the tree, one option is to use relative paths. If you are in then typing will work, because Downloads is an immediate child of your current directory. If you are in the subfolder and want to change directory ( ) to , you have to go up ( ) and then to . So the correct command would be /home/sharon cd Downloads Documents cd Downloads .. Downloads cd ../Downloads You could also enter an absolute path. So the folder is a subfolder of which is a subfolder of which is … (you get the idea :-)) So you can also enter wherever you are in the filesystem. Downloads sharon home cd /home/sharon/Downloads always refers to the home directory of the current user ( in your case). If you enter you'll land in your folder. ~ /home/sharon cd ~/Downloads Downloads refers to the current directory, so is roughly equivalent to . . cd ./Downloads cd Downloads means "parent directory". .. at the beginning of file path refers to the root directory. / The next nice thing is tab expansion. If you enter (last is pressing Tabulator key), the bash automatically expands it to cd ~/Dow Tab Tab cd ~/Downloads As the others said GNU/Linux is case sensitive. So it makes a difference if you enter , or . Furthermore I hope that you see now that there is a difference between and . Home hOme home /home home Ubuntu Community Ask! Developer Design Discourse Hardware Insights Juju Shop More command line - How do I navigate between direct... http://askubuntu.com/questions/232442/how-do-i... 1 of 3 10/16/2014 04:35 PM

Ubuntu Install2

Embed Size (px)

DESCRIPTION

ubuntu install

Citation preview

Page 1: Ubuntu Install2

sign up log in tour help

Take the 2-minute tour ×Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How do I navigate between directories in terminal?

I am new to Linux and Ubuntu and have tried changing to folders/directories with some difficulty.

Could someone explain why the following commands failed to change to the desired target

folder/directory?

sharon@sharon:~$ cd Home

bash: cd: Home: No such file or directory

sharon@sharon:~$ cd /Home

bash: cd: /Home: No such file or directory

sharon@sharon:~$ cd Documents

sharon@sharon:~/Documents$ cd Downloads

bash: cd: Downloads: No such file or directory

sharon@sharon:~/Documents$ cd /Downloads

bash: cd: /Downloads: No such file or directory

sharon@sharon:~/Documents$

command-line directory

edited Dec 25 '12 at 7:44Dec 25 '12 at 7:44

Sergey

22.9k 1 46 67

asked Dec 24 '12 at 21:18Dec 24 '12 at 21:18

n00b

467 4 8 25

4 Answers

The filesystem is GNU/Linux is like a tree, except that the root is on top. :-) So you have structure

like:

/

bin/

home/

sharon/

Documents/

Downloads/

fileA.txt

fileB.jpg

usr/

var/

If you want to move inside the tree, one option is to use relative paths. If you are in ,

then typing will work, because Downloads is an immediate child of your current

directory. If you are in the subfolder and want to change directory ( ) to ,

you have to go up ( ) and then to . So the correct command would be .

/home/sharon

cd Downloads

Documents cd Downloads

.. Downloads cd ../Downloads

You could also enter an absolute path. So the folder is a subfolder of which is a

subfolder of which is … (you get the idea :-)) So you can also enter

wherever you are in the filesystem.

Downloads sharon

home cd /home/sharon/Downloads

always refers to the home directory of the current user ( in your case). If you

enter you'll land in your folder.

~ /home/sharon

cd ~/Downloads Downloads

refers to the current directory, so is roughly equivalent to .. cd ./Downloads cd Downloads

means "parent directory"...

at the beginning of file path refers to the root directory./

The next nice thing is tab expansion. If you enter (last is pressing Tabulator key), the

bash automatically expands it to .

cd ~/Dow TabTab

cd ~/Downloads

As the others said GNU/Linux is case sensitive. So it makes a difference if you enter , or

. Furthermore I hope that you see now that there is a difference between and .

Home hOme

home /home home

Ubuntu Community Ask! Developer Design Discourse Hardware Insights Juju Shop More ›

command line - How do I navigate between direct... http://askubuntu.com/questions/232442/how-do-i...

1 of 3 10/16/2014 04:35 PM

Page 2: Ubuntu Install2

The first is adressed absolute while the last is relative to your current directory.

edited Dec 25 '12 at 7:50Dec 25 '12 at 7:50

Sergey

22.9k 1 46 67

answered Dec 24 '12 at 21:51Dec 24 '12 at 21:51

qbi

9,180 5 32 90

@ qbi: Wow, you're awesome. I love your detailed explanation on how to navigate among folders/directories. Are

you a teacher or professor in an educational institution? Most IT guys know a lot of IT stuff but breaking concepts

down to manageable and "digestible" chunks so that newbies can understand is only within the grasp of a handful

but gifted guys like you. n00b Dec 24 '12 at 22:04

– Thanks, and yes, I'm am a kind of teacher. :-) qbi Dec 24 '12 at 22:32

sharon@sharon:~$ cd Home

bash: cd: Home: No such file or directory

The little cedilla ~ indicates you are already in your /home/sharon directory. When you ask for 'cd

Home' the terminal looks for /home/sharon/Home. There is none.

sharon@sharon:~$ cd /Home

bash: cd: /Home: No such file or directory

Now you are asking, given the leading slash, to go to a directory above the current location; that is

/home/Home. There is none.

sharon@sharon:~$ cd Documents

sharon@sharon:~/Documents$

Success!

sharon@sharon:~/Documents$ cd /Downloads

bash: cd: /Downloads: No such file or directory

I'm not too sure where exactly this is. If you want to change from /home/sharon/Documents to

/home/sharon/Downloads, please try:

cd ~/Downloads

If you want to go directly to your home directory, that is /home/sharon, simply do:

cd

Also you can go Step back with

cd ..

And you can print the directory you are working in with (print working directory)

pwd

edited Dec 24 '12 at 22:12Dec 24 '12 at 22:12

a2r

74 6

answered Dec 24 '12 at 21:32Dec 24 '12 at 21:32

chili555

9,802 2 11 30

– @ chili555: Thanks a lot for helping newbies like me. Merry Christmas to you and your loved ones. n00b Dec 24

'12 at 21:46

1 – The leading slash indicates a path relative to the root, not one above the current directory. That would be ../

psusi Dec 25 '12 at 15:09

The command tells you why: There is no such directory.

Filenames are case sensetive, so it is /home, not /Home. Without a leading slash, it is assumed to be

relative to the current directory, and the Downloads directory is not in ~/Documents, nor is it in /,

but in your home directory, to which is a shortcut, thus it is ~/Documents.~

answered Dec 24 '12 at 21:22Dec 24 '12 at 21:22

psusi

19k 1 22 54

command line - How do I navigate between direct... http://askubuntu.com/questions/232442/how-do-i...

2 of 3 10/16/2014 04:35 PM

Page 3: Ubuntu Install2

– @ psusi: Thanks to you, too. Merry Christmas to you and your loved ones. n00b Dec 24 '12 at 21:48

– @ psusi: What does the leading slash mean? n00b Dec 24 '12 at 21:48

– @ psusi: What does ./<filename> mean? n00b Dec 24 '12 at 21:49

– @noob, means start from the root directory and means the current directory./ . psusi Dec 25 '12 at 15:05

I have to answer over this, because i can't comment on answers -.-

What does the leading slash mean? – n00b

it means that the thin you are talking about is a directory not a file. Files don't have to have file

endings like in Windows, so would be a file in your home-directory but

would be a directory/ a folder.

~/thisIsAFile

~/thisIsAFile/

What does ./ mean? – n00b

That means that the file you want to access is in your current directory.

Other usefull tips:

You can go a folder back with

cd ..

And you can get the path you are in with (print working directory)

pwd

edited Dec 25 '12 at 15:21Dec 25 '12 at 15:21 answered Dec 24 '12 at 22:01Dec 24 '12 at 22:01

a2r

74 6

@ a2r: Thanks for the clarification. I didn't know that files don't have file extensions like in Microsoft Windows. Do

programs have file extensions in Ubuntu too? n00b Dec 24 '12 at 22:18

Generally not, the system doesn't care what endings a file has, if its marked as executable ( google about chmod )

then you can run it as a programm. Also there is a global variable (google about it) called $PATH there are a view

directories saved (you can see which there are with ). And when you try to run a program like you typeecho $PATH

in the terminal. Your system looks throw the folders in $PATH and searches for gedit.gedit a2r Dec 25 '12 at

12:33

– That would be a trailing slash, not a leading slash. Also you must have a space in there before the ... psusi Dec

25 '12 at 15:07

– @ psusi: Sorry. I'm a bit confused here. What's a trailing slash? leading slash? Examples please? Thanks in advance.

n00b Dec 27 '12 at 13:36

command line - How do I navigate between direct... http://askubuntu.com/questions/232442/how-do-i...

3 of 3 10/16/2014 04:35 PM